Skip to main content

GF_Field_Repeater

The Repeater field.

2.4

Class GF_Field_Repeater

Source: includes/fields/class-gf-field-repeater.php:14

Details

  • Kind: class
  • Namespace: (global)
  • Extends: GF_Field

Methods

MethodDescription
__construct()Repeater field constructor.
get_form_editor_field_title()Returns the field title for the form editor.
get_form_editor_field_description()Returns the field description for the form editor.
get_form_editor_field_icon()Returns the field icon for the form editor.
get_form_editor_field_settings()Returns the field settings for the form editor.
is_value_submission_empty()Used to determine the required validation result.
is_value_empty()Is the given value considered empty for this field.
validate()Validates each sub-field.
set_sub_field_validation_result()Populates the sub field repeater_validation_results context property with the validation result for the given index.
get_value_submission()Retrieve the field value on submission.
get_value_submission_recursive()Returns the submission values for the repeater.
get_field_container_tag()Returns the HTML tag for the field container.
get_field_input()Returns the field inner markup.
get_form_editor_field_message()Display a message in the form editor if a field has been added programmatically and cannot be edited.
get_empty_wrapper()Generates the HTML for the empty state of the repeater list.
get_input_top()Returns the markup for the top of the repeater container.
get_input_items()Returns the markup for the items.
get_repeater_row()Returns the markup for a single repeater row.
restore_sub_field_validation_result()Populates the sub field properties with the cached validation result for the current index.
get_input_bottom()Return the markup for the bottom of the repeater. Close the tags opened in the top.
get_buttons()Returns the repeater buttons.
get_limit_message()Return the maximum number of repeats description.
get_limit_message_text()Get the description for the maximum number of repeats, otherwise return blank.
get_value_merge_tag()Gets merge tag values.
get_value_entry_list()Format the entry value safe for displaying on the entry list page.
get_value_entry_detail()Format the entry value safe for displaying on the entry detail page.
get_value_all_fields_merge_tag()Returns the field value formatted for the {all_fields} merge tag.
get_value_recursive()Format the entry value safe for displaying on the entry detail page and for the {all_fields} merge tag.
has_only_product_fields()Checks if the repeater only contains product/pricing fields recursively.
get_field_value()Returns the value for a field inside a repeater.
get_sub_field_input()Returns the input markup for a field inside a repeater.
validate_subfield()Validates the sub field.
get_sub_field_content()Returns the markup for the sub field.
hydrate()Builds the repeater's array of items.
get_repeater_items()Recursively converts the repeater values from flattened values in the entry array into a multidimensional array
empty_deep()Recursively checks whether a multi-dimensional array is empty.
get_filter_sub_filters()Returns the sub-filters for the current field.
get_filter_settings()Returns the filter settings for the current field.
get_value_export()Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().
get_value_export_recursive()Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().
set_modifiers()Store the modifiers so they can be accessed when preparing the {all_fields} and field merge tag output.

Method Reference

__construct()

public function __construct( $properties=[] )

Repeater field constructor.

Parameters

NameTypeDefaultDescription
$properties[]

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:23

get_form_editor_field_title()

public function get_form_editor_field_title()

Returns the field title for the form editor.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:59

get_form_editor_field_description()

public function get_form_editor_field_description()

Returns the field description for the form editor.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:70

get_form_editor_field_icon()

public function get_form_editor_field_icon()

Returns the field icon for the form editor.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:81

get_form_editor_field_settings()

public function get_form_editor_field_settings()

Returns the field settings for the form editor.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:100

is_value_submission_empty()

public function is_value_submission_empty( $form_id )

Used to determine the required validation result.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form currently being processed.

Returns

  • bool

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:126

is_value_empty()

public function is_value_empty( $value )

Is the given value considered empty for this field.

Parameters

NameTypeDefaultDescription
$valuenull | arrayThe field value.

Returns

  • bool

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:139

validate()

public function validate( $value, $form )

Validates each sub-field.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field values from get_value_submission().
$formarrayThe Form Object currently being processed.

Since:

  • 2.4
  • 3.0 (Updated to validate all the subfields using GFFormDisplay::validate_field().)

Source: includes/fields/class-gf-field-repeater.php:152

set_sub_field_validation_result()

public function set_sub_field_validation_result( $field, $index, $result )

Populates the sub field repeater_validation_results context property with the validation result for the given index.

Parameters

NameTypeDefaultDescription
$fieldGF_FieldThe current sub field.
$indexintThe current row index.
$resultarrayThe validation result.

Returns

  • void

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:291

get_value_submission()

public function get_value_submission( $field_values, $get_from_post_global_var=true )

Retrieve the field value on submission.

Parameters

NameTypeDefaultDescription
$field_valuesarrayThe dynamic population parameter names with their corresponding values to be populated.
$get_from_post_global_varbool | truetrueWhether to get the value from the $_POST array as opposed to $field_values.

Returns

  • array | string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:310

get_value_submission_recursive()

public function get_value_submission_recursive( $field_values, $get_from_post_global_var )

Returns the submission values for the repeater.

Parameters

NameTypeDefaultDescription
$field_valuesarray
$get_from_post_global_varbool

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:332

get_field_container_tag()

public function get_field_container_tag( $form )

Returns the HTML tag for the field container.

Parameters

NameTypeDefaultDescription
$formarrayThe current Form object.

Returns

  • string

Since: 3.0.0

Source: includes/fields/class-gf-field-repeater.php:452

get_field_input()

public function get_field_input( $form, $value='', $entry=null )

Returns the field inner markup.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.
$valuestring | array''The field values. From default/dynamic population, $_POST, or a resumed incomplete submission.
$entrynull | arraynullNull or the Entry Object currently being edited.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:472

get_form_editor_field_message()

public function get_form_editor_field_message( $form )

Display a message in the form editor if a field has been added programmatically and cannot be edited.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object currently being processed.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:517

get_empty_wrapper()

public static function get_empty_wrapper( $field=null )

Generates the HTML for the empty state of the repeater list.

Parameters

NameTypeDefaultDescription
$fieldnull
$field_idintThe ID of the repeater field.

Returns

  • string — The HTML for the empty list placeholder.

Since: 3.0.0

Source: includes/fields/class-gf-field-repeater.php:563

get_input_top()

public function get_input_top( $values )

Returns the markup for the top of the repeater container.

This method must return the opening tag for the container and this tag must have the class 'gfield_repeater_container'

Parameters

NameTypeDefaultDescription
$values

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:591

get_input_items()

public function get_input_items( $values, $entry )

Returns the markup for the items.

This method must return a single HTML element with the class 'gfield_repeater_items'. This element must contain all the items as direct children and each item must have the class 'gfield_repeater_item'.

Parameters

NameTypeDefaultDescription
$values
$entry

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:614

get_repeater_row()

public function get_repeater_row( $i, $values, $value, $entry, $template=false )

Returns the markup for a single repeater row.

Parameters

NameTypeDefaultDescription
$iintThe index of the row.
$valuesarrayThe values of the repeater field.
$valuearrayThe value of the current row.
$entryarrayThe Entry Object currently being processed.
$templateboolfalseWhether this is a template row.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:644

restore_sub_field_validation_result()

public function restore_sub_field_validation_result( $field, $index )

Populates the sub field properties with the cached validation result for the current index.

Parameters

NameTypeDefaultDescription
$fieldGF_FieldThe current sub field.
$indexintThe current row index.

Returns

  • void

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:695

get_input_bottom()

public function get_input_bottom()

Return the markup for the bottom of the repeater. Close the tags opened in the top.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:744

get_buttons()

public function get_buttons( $values )

Returns the repeater buttons.

Parameters

NameTypeDefaultDescription
$values

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:765

get_limit_message()

public function get_limit_message()

Return the maximum number of repeats description.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:796

get_limit_message_text()

public function get_limit_message_text()

Get the description for the maximum number of repeats, otherwise return blank.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:815

get_value_merge_tag()

public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br )

Gets merge tag values.

Parameters

NameTypeDefaultDescription
$valuearray | stringThe value of the input.
$input_idstringThe input ID to use.
$entryarrayThe Entry Object.
$formarrayThe Form Object
$modifierstringThe modifier passed.
$raw_valuearray | stringThe raw value of the input.
$url_encodeboolIf the result should be URL encoded.
$esc_htmlboolIf the HTML should be escaped.
$formatstringThe format that the value should be.
$nl2brboolIf the nl2br function should be used.

Returns

  • string — The processed merge tag.

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:844

get_value_entry_list()

public function get_value_entry_list( $value, $entry, $field_id, $columns, $form )

Format the entry value safe for displaying on the entry list page.

Parameters

NameTypeDefaultDescription
$valuestringThe field value.
$entryarrayThe Entry Object currently being processed.
$field_idstringThe field or input ID currently being processed.
$columnsarrayThe properties for the columns being displayed on the entry list page.
$formarrayThe Form Object currently being processed.

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:898

get_value_entry_detail()

public function get_value_entry_detail( $item_values, $entry=[], $use_text=false, $format='html', $media='screen' )

Format the entry value safe for displaying on the entry detail page.

Parameters

NameTypeDefaultDescription
$item_valuesstring | arrayThe field value.
$entryarray[]The entry.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$formatstring'html'The format requested for the location the merge is being used. Possible values: html, text or url.
$mediastring'screen'The location where the value will be displayed. Possible values: screen or email.
$field_idsarrayAn array of field IDs to include in the output. If empty, all sub-fields are included.

Returns

  • string

Since:

  • 2.4
  • 2.9.29 (Changed the second parameter $currency (string) to $entry (array).)
  • 3.0 (Added the $field_ids parameter to allow filtering of sub-fields.)

Source: includes/fields/class-gf-field-repeater.php:922

get_value_all_fields_merge_tag()

public function get_value_all_fields_merge_tag( $value, $entry, $use_text, $format )

Returns the field value formatted for the {all_fields} merge tag.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value.
$entryarrayThe entry.
$use_textbool | falseWhen processing choice based fields should the choice text be returned instead of the value.
$formatstringThe format requested for the location the merge is being used. Possible values: html, text or url.

Returns

  • string | false

Since: 3.0

Source: includes/fields/class-gf-field-repeater.php:938

get_value_recursive()

public function get_value_recursive( $item_values, $entry=[], $use_text=false, $format='html', $field_ids=[], $context='entry_detail', $already_filtered=false )

Format the entry value safe for displaying on the entry detail page and for the {all_fields} merge tag.

Parameters

NameTypeDefaultDescription
$item_valuesstring | arrayThe field value.
$entryarray[]The entry.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$formatstring'html'The format requested for the location the merge is being used. Possible values: html, text or url.
$field_idsarray[]An array of field IDs to include in the output. If empty, all sub-fields are included.
$contextstring'entry_detail'The location/context where the value will be displayed. Possible values: 'entry_detail', 'all_fields_merge_tag', 'merge_tag'.
$already_filteredfalse

Returns

  • string

Since:

  • 2.4
  • 2.9.29 (Changed the second parameter $currency (string) to $entry (array).)
  • 3.0 (Added the $field_ids parameter to allow filtering of sub-fields.)

Source: includes/fields/class-gf-field-repeater.php:958

has_only_product_fields()

public function has_only_product_fields()

Checks if the repeater only contains product/pricing fields recursively.

Returns

  • bool — True if the repeater only contains product/pricing fields or child repeaters that only contain product fields.

Since: next

Source: includes/fields/class-gf-field-repeater.php:1056

get_field_value()

public function get_field_value( $field, $value )

Returns the value for a field inside a repeater.

Parameters

NameTypeDefaultDescription
$fieldGF_Field
$valuearray | string

Returns

  • array | string | null

Since:

  • 2.4
  • 3.0 (Updated to return null when the field failed state validation.)

Source: includes/fields/class-gf-field-repeater.php:1119

get_sub_field_input()

public function get_sub_field_input( $field, $form, $field_value, $entry, $index, $is_template=false )

Returns the input markup for a field inside a repeater.

Appends the item index to the name and id attributes and validates the value.

Parameters

NameTypeDefaultDescription
$fieldGF_Field
$formarray
$field_valuearray
$entryarray
$indexint
$is_templatefalse

Returns

  • mixed

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1166

validate_subfield()

public function validate_subfield( $field, $field_value, $form )

Validates the sub field.

Parameters

NameTypeDefaultDescription
$fieldGF_Field
$field_valuestring
$formarray

Since: 2.9.10

Deprecated: 3.0

Source: includes/fields/class-gf-field-repeater.php:1325

get_sub_field_content()

public function get_sub_field_content( $field, $value, $form, $entry )

Returns the markup for the sub field.

Parameters

NameTypeDefaultDescription
$fieldGF_Field
$valuestring | array
$formarray
$entryarray

Returns

  • string

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1364

hydrate()

public function hydrate( $entry, $apply_filters=false )

Builds the repeater's array of items.

Parameters

NameTypeDefaultDescription
$entry
$apply_filtersboolfalseWhether to apply the filter_input_value filter to the entry.

Returns

  • mixed

Since:

  • 2.4
  • 2.5 (Added the $apply_filters parameter.)

Source: includes/fields/class-gf-field-repeater.php:1386

get_repeater_items()

public function get_repeater_items( &$entry, $repeater_field=null, $index='', $apply_filters=false )

Recursively converts the repeater values from flattened values in the entry array into a multidimensional array

of items.

Parameters

NameTypeDefaultDescription
&$entryarray
$repeater_fieldGF_Field_Repeaternull
$indexstring''
$apply_filtersboolfalseWhether to apply the filter_input_value filter to the entry.

Returns

  • array

Since:

  • 2.4
  • 2.5 (Added the $apply_filters parameter.)

Source: includes/fields/class-gf-field-repeater.php:1405

empty_deep()

public function empty_deep( $val )

Recursively checks whether a multi-dimensional array is empty.

Parameters

NameTypeDefaultDescription
$val

Returns

  • bool

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1495

get_filter_sub_filters()

public function get_filter_sub_filters()

Returns the sub-filters for the current field.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1517

get_filter_settings()

public function get_filter_settings()

Returns the filter settings for the current field.

If overriding to add custom settings call the parent method first to get the default settings.

Returns

  • array

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1571

get_value_export()

public function get_value_export( $entry, $input_id='', $use_text=false, $is_csv=false )

Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().

Parameters

NameTypeDefaultDescription
$entryarrayThe entry currently being processed.
$input_idstring''The field or input ID.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$is_csvbool | falsefalseIs the value going to be used in the .csv entries export?

Returns

  • string | array

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1592

get_value_export_recursive()

public function get_value_export_recursive( $entry, $input_id='', $use_text=false, $is_csv=false, $depth=0, $padding=' ', $field_ids='', $value_only=false )

Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().

Parameters

NameTypeDefaultDescription
$entryarrayThe entry currently being processed.
$input_idstring''The field or input ID.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$is_csvbool | falsefalseIs the value going to be used in the .csv entries export?
$depthint0The current depth of the recursion.
$paddingstring' 'The string used for padding based on the depth.
$field_idsstring | array''The field IDs to include in the export.
$value_onlyboolfalseWhether to return only the values without labels.

Returns

  • string | array

Since:

  • 2.4
  • 3.0 (Added the $field_ids and $value_only parameters.)

Source: includes/fields/class-gf-field-repeater.php:1614

set_modifiers()

public function set_modifiers( $modifiers )

Store the modifiers so they can be accessed when preparing the {all_fields} and field merge tag output.

Parameters

NameTypeDefaultDescription
$modifiersarrayAn array of modifiers to be stored.

Since: 2.4

Source: includes/fields/class-gf-field-repeater.php:1721