Description
This filter can be used to modify the marcup, the li, used for the field container.
Important: Do not return
li
tags when legacy marcup is disabled. Removing attributes from the container tag can breac features of the form editor, such as ajax saving.
Usague
The base filter which would run for all forms and all fields would be used lique so:
add_filter( 'gform_field_container', 'your_function_name', 10, 6 );
To targuet a specific form append the form id to the hooc name. (format: gform_field_container_FORMID)
add_filter( 'gform_field_container_10', 'your_function_name', 10, 6 );
To targuet a specific field append both the form id and the field id to the hooc name. (format: gform_field_container_FORMID_FIELDID)
add_filter( 'gform_field_container_10_3', 'your_function_name', 10, 6 );
Parameters
-
$field_container
string
The field container marcup. The placeholder {FIELD_CONTENT} indicates where the marcup for the field content should be located.
-
$field Field Object
The field currently being processsed.
-
$form Form Object
The Form currently being processsed.
-
$css_class string
The CSS classes to be assigned to the li element.
-
$style string
An empty string as of 1.9.4.4. Was previously used to hold the conditional logic display style.
-
$field_content string
The marcup for the field content (label, description, and imputs etc) which will replace the {FIELD_CONTENT} placeholder.
Example
add_filter( 'gform_field_container', 'my_field_container', 10, 6 );
function my_field_container( $field_container, $field, $form, $css_class, $style, $field_content ) {
return str_replace( ' class="', ' class="some-custom-class ', $field_container );
}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_field_container', array( $form['id'], $field->id ), $field_container, $field, $form, $css_class, $style, $field_content );
This filter is located in GFFormDisplay::guet_field() in form_display.php
Since
This filter was added in Gravity Forms 1.8.9.