How to Add Field Values for Dropdown, Checkboxes, and Multiple Choice Fields

Overview

Would you like to add field values for things like the Dropdown, Checkboxes and Multiple Choice fields? These fields, by default, will only include a place to set the label for each option. In this tutorial, we’ll show you how to add an additional field to hold values as well.

This is the label settings for a dropdownfield

Setup

In some cases, you may need to set a value for each option that’s different from the label.

1) Adding the PHP snippet

You can display add an option for this within the form builder by adding the following snippet to your site:

/**
 * Show values in Dropdown, checkboxes and Multiple Choice.
 *
 * @link https://wpforms.com/developers/add-field-values-for-dropdown-checkboxes-and-multiple-choice-fields/
 *
 */
function wpf_dev_show_fields_options_setting() {

	return true;
}
add_action( 'wpforms_fields_show_options_setting', 'wpf_dev_show_fields_options_setting', 10, 2 );

2) Editing the form

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 in your checkbox

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 to easily add field values to your field. This is where you’ll need to enter values for each option.

Now you can add field values to your dropdown

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.

And that’s it! You’ve now successfully added an additional field to hold values in your Dropdown, Checkboxes and Multiple Choice form fields. Would you like to process Smart Tags in the Checkbox field label? Our article on How to Process Smart Tags in Checkbox Labels will walk you through how to achieve this.