Skip to content

Commit

Permalink
fix: loading saved data from sessionData
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Mar 24, 2022
1 parent 572cfb7 commit 7850bc7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/ManyField.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ public function FieldList() {

if ($this->value) {
foreach ($this->value as $record) {
$output->push($this->generateRow($index++, $record));
$row = $this->generateRow($index++, $record);
$output->push($row);
}
} else {
// display one if none exist.
Expand Down Expand Up @@ -655,13 +656,28 @@ public function generateRow($index, $value = null, $prefixName = true)

foreach ($this->manyChildren as $child) {
$field = clone $child;
$originalName = $field->name;
$field = $this->updateManyNestedField($field, $index, $value, $prefixName);

$field = $field->setReadonly($this->readonly);
$field = $field->setDisabled($this->readonly);

if ($value && is_object($value) && $value->hasMethod('modifyManyRecordField')) {
$field = $value->modifyManyRecordField($field);
if ($value) {
if (is_object($value) && $value->hasMethod('modifyManyRecordField')) {
$field = $value->modifyManyRecordField($field);
} else {
$value = $this->value;

if (is_object($value)) {
$field = $field->setValue($value->{$field->name}, $value);
} else if (is_array($value)) {
if (isset($value[$originalName])) {
$field = $field->setValue((isset($value[$originalName][$index])) ? $value[$originalName][$index] : null);
} elseif (isset($value[$index][$originalName])) {
$field = $field->setValue((isset($value[$index][$originalName])) ? $value[$index][$originalName] : null);
}
}
}
}

if ($field) {
Expand Down

0 comments on commit 7850bc7

Please sign in to comment.