Flexible-Repeater
A flexible repeater field allows users to create a set of fields that can be repeated multiple times within a form, with each repetition based on a predefined set of options. It provides the flexibility to define various field sets and choose from them dynamically. This field type also includes a drag-and-drop interface for sorting the repeated entries, enhancing usability for managing complex data structures, such as multi-option product features or customizable service packages.
Screenshots
Field render in form:
![]()
Field render in field group:
Configuration
-
Settings:
- Name: The label for the field.
- Slug: The unique technical identifier.
- Fields: The individual fields that are included within each repetition of the repeater.
-
Validation:
- Require: Determines if at least one set of fields must be filled out.
- Number min of elements: Minimum number of repetitions required.
- Number max of elements: Maximum number of repetitions allowed.`
-
Design:
- Instructions: Text displayed alongside the field providing details about the data needed.
- Width: The width of the field in the form.
- Classes: Custom CSS classes for styling the field.
- ID: Custom ID attribute for the field.
- Text before: Additional text displayed before the field.
- Text after: Additional text displayed after the field.
Return format
- Type: array
- Value:
[
[
'type' => 'option_slug_1'
'values' => [
'sub_field_slug_one' => 'First element value',
]
],
[
'type' => 'option_slug_2'
'values' => [
'sub_field_slug_two' => 'Second element value',
]
],
]
Usage
/some-template.tpl
{* Object or Entity and Id *}
{assign var="data" value=$modules.customfieldgroups.data->get($product)}
{assign var="data" value=$modules.customfieldgroups.data->get('product', $product.id)}
{foreach from=$data.field_group_slug.field_slug item=row}
{if $row.type eq "group_slug_one"}
{include file=".." item=$row.values}
{elseif $row.type eq "group_slug_two"}
{include file=".." item=$row.values}
{/if}
{/foreach}
/SomeClass.php
function someMethod()
{
$dataRetriever = DataRetrieverFacade::getInstance();
$data = $dataRetriever->get($object); // Object
$data = $dataRetriever->get('product', $idProduct); // Entity and id
$elements = $data['field_group_slug']['field_group_slug'];
foreach($elements as $element) {
$values = $element['values'];
switch($element['type']) {
case "group_slug_one":
..
break;
case "group_slug_two":
..
break;
..
}
}
}

