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
| Method | Description |
|---|---|
__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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | null | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field values from get_value_submission(). | |
$form | array | The Form Object currently being processed. |
Since:
2.43.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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The current sub field. | |
$index | int | The current row index. | |
$result | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$field_values | array | The dynamic population parameter names with their corresponding values to be populated. | |
$get_from_post_global_var | bool | true | true | Whether 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
| Name | Type | Default | Description |
|---|---|---|---|
$field_values | array | ||
$get_from_post_global_var | bool |
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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The Form Object currently being processed. | |
$value | string | array | '' | The field values. From default/dynamic population, $_POST, or a resumed incomplete submission. |
$entry | null | array | null | Null 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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$field | null | ||
$field_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$i | int | The index of the row. | |
$values | array | The values of the repeater field. | |
$value | array | The value of the current row. | |
$entry | array | The Entry Object currently being processed. | |
$template | bool | false | Whether 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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The current sub field. | |
$index | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$value | array | string | The value of the input. | |
$input_id | string | The input ID to use. | |
$entry | array | The Entry Object. | |
$form | array | The Form Object | |
$modifier | string | The modifier passed. | |
$raw_value | array | string | The raw value of the input. | |
$url_encode | bool | If the result should be URL encoded. | |
$esc_html | bool | If the HTML should be escaped. | |
$format | string | The format that the value should be. | |
$nl2br | bool | If 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | The field value. | |
$entry | array | The Entry Object currently being processed. | |
$field_id | string | The field or input ID currently being processed. | |
$columns | array | The properties for the columns being displayed on the entry list page. | |
$form | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$item_values | string | array | The field value. | |
$entry | array | [] | The entry. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$format | string | 'html' | The format requested for the location the merge is being used. Possible values: html, text or url. |
$media | string | 'screen' | The location where the value will be displayed. Possible values: screen or email. |
$field_ids | array | An array of field IDs to include in the output. If empty, all sub-fields are included. |
Returns
string
Since:
2.42.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
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The field value. | |
$entry | array | The entry. | |
$use_text | bool | false | When processing choice based fields should the choice text be returned instead of the value. | |
$format | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$item_values | string | array | The field value. | |
$entry | array | [] | The entry. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$format | string | 'html' | The format requested for the location the merge is being used. Possible values: html, text or url. |
$field_ids | array | [] | An array of field IDs to include in the output. If empty, all sub-fields are included. |
$context | string | 'entry_detail' | The location/context where the value will be displayed. Possible values: 'entry_detail', 'all_fields_merge_tag', 'merge_tag'. |
$already_filtered | false |
Returns
string
Since:
2.42.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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | ||
$value | array | string |
Returns
array|string|null
Since:
2.43.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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | ||
$form | array | ||
$field_value | array | ||
$entry | array | ||
$index | int | ||
$is_template | false |
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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | ||
$field_value | string | ||
$form | array |
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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | ||
$value | string | array | ||
$form | array | ||
$entry | array |
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
| Name | Type | Default | Description |
|---|---|---|---|
$entry | |||
$apply_filters | bool | false | Whether to apply the filter_input_value filter to the entry. |
Returns
mixed
Since:
2.42.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
| Name | Type | Default | Description |
|---|---|---|---|
&$entry | array | ||
$repeater_field | GF_Field_Repeater | null | |
$index | string | '' | |
$apply_filters | bool | false | Whether to apply the filter_input_value filter to the entry. |
Returns
array
Since:
2.42.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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry currently being processed. | |
$input_id | string | '' | The field or input ID. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$is_csv | bool | false | false | Is 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
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry currently being processed. | |
$input_id | string | '' | The field or input ID. |
$use_text | bool | false | false | When processing choice based fields should the choice text be returned instead of the value. |
$is_csv | bool | false | false | Is the value going to be used in the .csv entries export? |
$depth | int | 0 | The current depth of the recursion. |
$padding | string | ' ' | The string used for padding based on the depth. |
$field_ids | string | array | '' | The field IDs to include in the export. |
$value_only | bool | false | Whether to return only the values without labels. |
Returns
string|array
Since:
2.43.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
| Name | Type | Default | Description |
|---|---|---|---|
$modifiers | array | An array of modifiers to be stored. |
Since: 2.4
Source: includes/fields/class-gf-field-repeater.php:1721