Support is currently limited. See our hours of operation.

This help desk is no longer actively support. We have switched to a ticketing system to more smoothly manage support, and free up development time. Your newly created tickets won't be available here. You will instead have an email history of your new tickets.

We are working on moving everything current and helpful from public tickets into the docs. This will be a long process and in the meantime, public tickets will remain searchable.

Your private tickets will remain available to you indefinitely. See your old tickets.

Help Desk

"Other" Option for Data From Entries Field

Labels

This Ticket is public

Notifications

Making a "state/city dependent dropdown" as described here, https://formidableforms.com/knowledgebase/dynamic/ , I find myself in need of an "Other" option/field. Obviously I can make "Other" appear as an option by simply importing a city named "Other" for each state... but it appears that Formidable regards all the 'other' options as distinct for the purpose of setting a conditional.

Obviously one could up a conditional on the "other" field to match the "other" option for every single state, but that seems like a stupid solution. Is there a better way?

A few things that don't seem to work:

Setting up an intermediary hidden field to trigger the conditional (can't get value from cities field)
Setting the "other" field to respond to responses "like" one of the "other" responses.

So when a user selects "Other" in your City field, you would like a text input field to appear, right?

Yes, exactly.

Does it work to add a text field to your form and add conditional logic on it that says "Show this field if City is equal to Other"?

No, because Formidable treats each possible "other" option in the city dropdown as different.

In other words, I can set a piece of conditional logic as you describe that makes it work properly for
"Michigan" > "Other" but that same logic won't work for "New York" > "Other"

As I said in my initial post, I could in theory get this to work by setting up a specific piece of conditional logic for every single "State" > "Other" combination, but that seems like a really stupid way to do this.

Ah, I see what you're saying. It looks like this will require some custom code. There is actually a change included in the next version that changes when a particular hook fires. This change makes it so the following code can add an "Other" option to your City field:

add_filter('frm_setup_new_fields_vars', 'frm_set_checked', 20, 2);
function frm_set_checked($values, $field){
    if($field->id == 37558){//Replace with the ID of your City field
	$values['options'][] = "Other";
    }
    return $values;
}

Then, the other problem you're dealing with is the conditional logic. Since you can't select "City field is equal to Other", you will have to add your own javascript to do this. You can add something like this to your form's Settings > Customize HTML in the Before Fields:

<script type="text/javascript">
jQuery(document).ready(function($){
$('#frm_field_37562_container').css('display','none');

$(document).on('change', 'select[name="item_meta[37558]"]', function(){
  var val1 = $('select[name="item_meta[37558]"]').children("option").filter(":selected").text();
if (val1 == "Other")
 { $('#frm_field_37562_container').css('display','block'); }
else
{ $('#frm_field_37562_container').css('display','none'); }
});
}) ;

</script>

Change 37562 to the ID of your field that will show if other is selected. Change 37558 to the ID of your City field.

This works, thank you!

The only problem with the solution above is that if you choose a state with no cities, you get only the "other" option, and because you can't change the value of the "city" field, there is no way to trigger the display of the "other" field. Adding a separate .ajaxComplete() driven function to count the number of entries in the city field and show the "other" field if there is only one solved this issue. I also added a bit of script to hide and clear the "other" field when the state is changed. Code sample below.

$(document).on('change', 'select[name="item_meta[238]"]', function(){
$('#frm_field_253_container').css('display','none');
$('#frm_field_253_container :input').val('');
$( document ).ajaxComplete(function() {
var val3 = $('#field_2j934p option').length;
if (val3 == "1")
{ $('#frm_field_253_container').css('display','block');
}
else
{ }
});
});

Thanks for sharing. I'm glad you were able to get it working!

Ticket closed.