gform_repeater_sub_field_input

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

ParameterTypeDescription
$inputstringThe updated HTML for the sub-field input.
$fieldGF_FieldThe sub-field object.
$formarrayThe form object.
$field_valuemixedThe value of the sub-field.
$entryarrayThe entry object.
$indexint|stringThe index of the repeater item.
$is_templateboolWhether 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