Skip to content

Commit

Permalink
Merge pull request #18 from Cheppers/support-repeatable-fields
Browse files Browse the repository at this point in the history
Add repeatable property to text element to support repeatable settings
  • Loading branch information
Dénes Gulyás authored Feb 17, 2021
2 parents 321c943 + 5ff3693 commit be58c2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

/bin/
/reports/
/vendor/

.phpunit.result.cache
6 changes: 6 additions & 0 deletions src/DataTypes/ElementTextMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class ElementTextMeta extends Base
*/
public $validation = [];

/**
* @var array
*/
public $repeatable = [];

/**
* {@inheritdoc}
*/
Expand All @@ -30,6 +35,7 @@ protected function initPropertyMapping()
[
'is_plain' => 'isPlain',
'validation' => 'validation',
'repeatable' => 'repeatable',
]
);

Expand Down
7 changes: 7 additions & 0 deletions src/DataTypes/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,17 @@ protected function getSubElements(array $elementData)
$elements = [];

foreach ($elementData as $element) {
if (empty($element)) {
continue;
}
$class = ElementSimpleChoice::class;
if (isset($element['file_id'])) {
$class = ElementSimpleFile::class;
}
if (!is_array($element)) {
$class = ElementSimpleText::class;
$element = ['value' => $element];
}
/** @var \Cheppers\GatherContent\DataTypes\ElementBase[] $elements */
$elements[] = new $class($element);
}
Expand Down

0 comments on commit be58c2a

Please sign in to comment.