Description
The wpforms_field_properties
filter fires on form load to display the field properties such as labels, sublabels, and descriptions.
Parameters
- $properties
- (array) An array of field properties such as labels, sublabels and description.
- $field
- (array) Sanitized field data.
- $form_data
- (array) Processed form settings/data, prepared to be used later.
Source
wpforms/pro/includes/class-frontend.php
More Information
The wpforms_field_properties
filter is applied to an array for specific form field properties. Using this filter will change every form field.
Each form field will have its own unique filter name, see the section below for a complete list of documented examples. For example, if you only wanted to change the Email form field, you would use wpforms_field_properties_email
.
Examples
In this example shown below, the function will have the field Description displayed above the field itself but only for the form ID 225.
/** * Move the field description above the form field. * * @link https://wpforms.com/developers/wpforms_field_properties/ * * @param array $properties Field properties. * @param array $field Field settings. * @param array $form_data Form data and settings. * * @return array */ function wpf_dev_field_properties( $properties, $field, $form_data ) { // Only process this snippet on the form ID 225 if ( absint( $form_data[ 'id' ] ) !== 225 ) { return $properties; } // move the field description from under the form field to above the form field $properties[ 'description' ][ 'position' ] = 'before'; return $properties; } add_filter( 'wpforms_field_properties', 'wpf_dev_field_properties', 10, 3 );
Related
Article References:
- How to Position the Field Description Above the Form Field
- How to Change Sublabels for the Email Field
- How to Process Smart Tags in HTML Fields
- How to Change Sublabels for the Name Field
- How to Change the Address Field Sublabels
- How to Change the Password Field Sublabels
- How to Change Sublabels for the Credit Card Field
- How to Change the Name Attribute of a Hidden Field