1. Home
  2. Snippets
  3. Add field values for Dropdown, Checkboxes, and Multiple Choice fields

Add field values for Dropdown, Checkboxes, and Multiple Choice fields

Heads up!

This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

For extra guidance, please see WPBeginner's tutorial on adding custom code.

Dismiss

Dropdown, Checkboxes, and Multiple Choice fields, by default in WPForms, will only include a place to set the label for each option.

Label settings for a Dropdown field in WPForms

In some cases, you may need to set a value for each option that’s different from the label. You can display on option for this within the form builder by adding the following snippet to your site:

add_filter( 'wpforms_fields_show_options_setting', '__return_true' );

After adding this code, you’ll need to refresh the form builder page. Then, click on the Dropdown/Checkboxes/Multiple Choice field to open its Field Options panel.

Next, open Advanced Options and check the new box labeled Show Values.

Show Values checkbox in WPForms

Once this box is checked, you can scroll back up to the options. Now, you should see an additional input box below each option label. This is where you’ll need to enter values for each option.

Value inputs displayed under each label input

Note: While the raw value is stored in the database entry, it’s not included in the {all_fields} Smart Tag for email notifications, when viewing the entry in WordPress admin, or within CSV exports.

To display the value for a field in either a form’s confirmation message or notification email, you’ll need use the following Smart Tag format:

{field_value_id="X"}

Just replace the X with the field ID, and this Smart Tag will automatically pull the value for any selected option(s) in that field.

Updated on July 19, 2018

Was this article helpful?