NB: Make sure you do a back up of your theme, files and database before attempting the tutorials

Adding a Default Value in a Formidable Form field with Drop Down Menu
Easy

---- Last modified : Oct 01 2022

Estimated reading time : 1 minute, 50 seconds - 254 words

With this tutorial, we will show you how to add a Selected text value in a drop down menu linked to a matching Posts or Post Type in a Formidable Form.

In order to do so, we need a drop-down field in our form that we will call Countries for our example (it’s a type of taxonomy; you can name it fruits if you want). Do not add any choices manually.

Save your form and then head to Settings > Form actions.

Then select Create a post (if that is not already done – This will create a post entry or post type matching your form parameters and fields included). Select the fields matching the post ou post type.

For your taxonomy, go the Taxation/Category section, then add your taoxnomy’s name and select the field you’ve created for your dynamic input of your taxonomy i.e. it will contain all choices added in the Select option from the Taxation/Category section.

Here’s an example:

The problem is that your Formidable Form does not give you a default value or first category in alphabetical order. So if you don’t want the field to look empty, you need to use the Formidable Form frm_dropdown_cat filter.

Here’s the filter:

Adding a default value – Formidable Form drop-down taxonomy

In this filter, you’ll notice that 139 is the ID of our drop down menu field. Simply replace it with your ID.
Add this filter in your theme’s functions.php file.

add_filter('frm_dropdown_cat', 'nomdevotrefonction', 10, 2);
function nomdevotrefonction($args, $field){
  if($field['id'] == 139){ //change 25 to the ID of your field
    ///// Donner ici le nom htlm de votre texte
    $args['show_option_all'] = '- Sélectionner -';
  }
  return $args;
}

Results:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>