Description
The wpforms_textarea_field_display
fires on the 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 for specific 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 shown below, the function will allow Smart Tags to be processed on field labels for the form ID 365
. Just remember to change the form ID from 365 to match the specific form ID you’re wanting to run your code on.
Removing that check would run the code for all forms.
/**
* Run smart tags on all field labels.
*
* @link https://wpforms.com/developers/wpforms_textarea_field_display/
*
* @param array $field Sanitized field data.
* @param array $field_atts Field attributes.
* @param array $form_data Form data and settings.
*
* return array
*/
function wpf_dev_textarea_field_display( $field, $field_atts, $form_data ) {
if ( $form_data[ 'id' ] != 365 ) {
return $field;
}
$field[ 'label' ] = wpforms()->smart_tags->process( $field[ 'label' ], $form_data );
return $field;
}
add_filter( 'wpforms_textarea_field_display', 'wpf_dev_textarea_field_display', 10, 3 );