Skip to content

Commit

Permalink
Fix empty repeater save value
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Jan 25, 2025
1 parent 9993e75 commit 48f7176
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/backend/formwidgets/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,18 @@ protected function loadAssets()
*/
public function getSaveValue($value)
{
return (array) $this->processSaveValue($value);
return $this->processSaveValue($value);
}

/**
* Splices in some meta data (group and index values) to the dataset.
* @param array $value
* @return array
* @return array|null
*/
protected function processSaveValue($value)
{
if (!is_array($value) || !$value) {
return $value;
return null;
}

if ($this->minItems && count($value) < $this->minItems) {
Expand Down
4 changes: 4 additions & 0 deletions modules/backend/formwidgets/repeater/partials/_repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
data-sortable-handle=".<?= $this->getId('items') ?>-handle"
<?php endif; ?>
>
<?php if (!$this->previewMode): ?>
<input type="hidden" name="<?= $field->getName(); ?>">
<?php endif ?>

<ul id="<?= $this->getId('items') ?>" class="field-repeater-items">
<?php foreach ($formWidgets as $index => $widget): ?>
<?= $this->makePartial('repeater_item', [
Expand Down

0 comments on commit 48f7176

Please sign in to comment.