Description
The gform_repeater_sub_field_input filter allows developers to make further adjustments to the sub-field markup before it is rendered. When a Repeater field is rendered, Gravity Forms grabs the markup of each sub-field and adjusts the name, id, and aria attributes to include the sub-field index.
Usage
add_filter( 'gform_repeater_sub_field_input', 'your_function_name', 10, 7 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$input | string | The updated HTML for the sub-field input. |
$field | GF_Field | The sub-field object. |
$form | array | The form object. |
$field_value | mixed | The value of the sub-field. |
$entry | array | The entry object. |
$index | int|string | The index of the repeater item. |
$is_template | bool | Whether this is a template row. |
Examples
Turn off browser autocomplete for a sub-field.
add_filter( 'gform_repeater_sub_field_input', 'disable_repeater_sub_field_autocomplete', 10, 7 );
function disable_repeater_sub_field_autocomplete( $input, $field, $form, $field_value, $entry, $index, $is_template ) {
// Only target field 5 on form 1.
if ( (int) rgar( $form, 'id' ) !== 1 || (int) $field->id !== 5 ) {
return $input;
}
$html_processor = WP_HTML_Processor::create_fragment( $input );
while ( $html_processor->next_tag( array( 'tag_name' => 'input' ) ) ) {
$html_processor->set_attribute( 'autocomplete', 'off' );
}
return $html_processor->get_updated_html();
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This filter was added in Gravity Forms 3.2.0
Source Code
gravityforms/includes/fields/class-gf-field-repeater.php