Home › Forums › General Issues › Select Field + Add your own option?
I’m trying to build a select field that also gives the user the option to enter something not part of the options.
Example:
– Academic Title –
BA
MA
PhD
Other: _______
I’m probably not the first one to do this, so I was wondering whether there was some way to do this with just one field? Or maybe there is some other solution that is more elegant than select field + text field?
Hi @dtx211
Thanks for the post.
Is it an option to switch to the Checkbox field type?
This field contains an option to add a custom choice value out of the box.
Please checkout this fieldtype here: https://www.advancedcustomfields.com/resources/checkbox/
I hope this info helps.
@acf-support any chance we can reconsider this?
A checkbox/radio is a bit of a non-starter for large data sets.
This really helps support a feature akin to ‘tagging’
I would also appreciate if this feature could be included in one of the next versions. As drewcovi already mentioned, checkboxes or radio boxes are not pratical if you have to deal with a great amount of values. So it would great, if the select box (search function) would also get this feature 🙂
+1
This would be really helpful for select fields with long lists.
You can visit Spirit Airlines Number to get real-time support, without wasting time reading information to send email to Spirit Airlines Phone Number.
+1 or am I missing something and this has been resolved? I still don’t see the option or add an other field on Select in ACF
The checkbox option does not work anyway, because if you add for example “red : Red” then it actually saves the value AND label as “red : Red” and does not save the value “red” with label “Red”.
I am trying to figure out how I can allow my customer to enter a value in a post which is then re-displayed later in other posts as an option. So they can build up values on the fly. I really dont want them editing the ACF field settings to add in new options. So almost like a tag cloud. I am surprised there is no tag cloud field. We cant use taxonomies as its only to show on a few pages. But I need to reference its slug in the code, so I need them to add something like “my-customer : My Customer” and then when they add a new post its showing “My Customer” in the drop down and saves using value “my-customer” because I need to reference the slug later not value.
I did add some code that allows them to choose from a list of values in the database and then populate a text field by clicking one of those values. That works like a tag cloud (although I am only allowing one entry), but I realised I dont have the value slug saved and hidden behind the scenes. If interested here is the code that could be adapted into a Select dropdown but it doesn’t save the slug. Maybe I can with further code:
function modify_project_field( $field )
{
global $wpdb;
$projects_array = $wpdb->get_results("SELECT DISTINCT meta_value FROM $wpdb->postmeta pm WHERE meta_key = 'my_project'",ARRAY_A);
foreach($projects_array AS $project)
{
$projects[] = $project['meta_value'];
}
foreach($projects AS $project)
{
$project_links[] = '<a href="#" class="my-select-value" data-value="'.$project.'">'.$project.'</a>';
}
if($project_links)
{
echo '<p>Enter a new value or choose from existing:<br/>';
echo implode(', ', $project_links).'</p>';
echo "
<script>
jQuery('.my-select-value').on('click', function()
{
var field = jQuery('#acf-field_6346f63fec6c2');
var value = jQuery(this).attr('data-value');
field.val(value);
});
</script>
";
}
}
add_action('acf/render_field/key=field_6346f63fec6c2', 'modify_project_field');
The topic ‘Select Field + Add your own option?’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.