Description

The wpforms_checkbox_field_display fires on form load to display the field attributes such as label and description.

Parameters

$field
(array) Sanitized field data.
$field_atts
(array) An array of field attributes such as label and description.
$form_data
(array) Processed form settings/data, prepared to be used later.

Source

wpforms/includes/fields/class-base.php

More Information

This filter is applied to an array of form field attributes. Each form field will have its own unique name, for further information and examples, please review this snippet tutorial.

Examples

In this example, we’re using this filter to allow for WPForms Smart Tags to be used on every Checkbox form field label.

/**
 * Using Smart Tags in Checkbox field labels.
 *
 * @link https://wpforms.com/developers/wpforms_checkbox_field_display/
 */
 
function wpf_dev_checkbox_choices_process_smarttags( $field, $deprecated, $form_data ) {

    foreach ( $field[ 'choices' ] as $key => $choice ) {

        if ( ! empty( $choice[ 'label' ] ) ) {

            $field[ 'choices' ][ $key ][ 'label' ] = apply_filters( 'wpforms_process_smart_tags', $choice[ 'label' ], $form_data );

        }

    }

    return $field;
}
add_filter( 'wpforms_checkbox_field_display', 'wpf_dev_checkbox_choices_process_smarttags', 10, 3 );

Reference Articles