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

Introduction

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.

Adding the snippet to add field values

To begin, you’ll need to add this snippet to your site. If you need assistance in how to add snippets to your site, please see this tutorial.

/**
 * Show values in Dropdown, checkboxes, and Multiple Choice.
 *
 * @link https://wpforms.com/developers/add-field-values-for-dropdown-checkboxes-and-multiple-choice-fields/
 *
 */
 
add_action( 'wpforms_fields_show_options_setting', '__return_true' );

Creating your form

Next, you’ll need to create your form and add your Dropdown, Checkbox or Multiple Choice form field. In this tutorial, we’re adding a dropdown field of color choices.

If you need help in creating your form, please see this documentation.

Enabling the Show Value setting in the form builder

Once you’ve added your Dropdown, Checkbox or Multiple Choice form field and entered your choice options, click on the Advanced tab and click the toggle to Show Values and click Save on the form to save the changes.

click the toggle to Show Values on the Advnaced tab of the form field

When you go back to the General tab, you’ll see you can now add additional field values to each option in the dropdown and re-save the form.

add field values to each option and save the form again

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.

Filter Reference: wpforms_fields_show_options_setting