Hi guys,
We’ve just ran onto the issue where nested repeaters doesn’t allow additional occurrences.
Page builder uses repeater for content blocks,
then blocks use repeater for rows,
and then some of the rows use additional repeater for content lines.
One of the pages got a bit complex; section is repeated multiple times; first 6 were completely fine, but 7th causes an issue making the whole entry unusable.
Error states: ““array_flip(): Can only flip string and integer values, entry skipped” on line 53 of /public/modules/backend/formwidgets/repeater/HasRelationStore.php” on line 618 of /public/modules/backend/classes/Controller.php
points to the following function:
protected function getLoadValueFromRelation()
{
if ($this->relatedRecords !== null) {
return $this->relatedRecords;
}
// @deprecated This could be refactored to always use deferred binding
// and make sure the array keys match the model keys and drop the _id
if ($this->isLoaded) {
$value = $this->getLoadedValueFromPost();
$ids = is_array($value) ? array_map(function($v) {
return $v['_id'] ?? null;
}, $value) : [];
$records = $this->getRelationQuery()->find($ids);
if ($records) {
$indexes = array_flip($ids);
foreach ($records as $model) {
$rIndex = $indexes[$model->getKey()] ?? null;
if ($rIndex !== null) {
$this->relatedRecords[$rIndex] = $model;
}
}
}
}
else {
$this->relatedRecords = $this->getRelationObject()
->withDeferred($this->getSessionKey())
->get()
->all()
;
}
return $this->relatedRecords;
}
I’m guessing it’s a known issue due to the comment, however, it may be worth flagging to move it up the priority list!