Skip to content

Commit dfd2797

Browse files
committed
HasManyLocal: apply getInstance() method for also created records
1 parent 16d4f91 commit dfd2797

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Form/Related/Forms/HasManyLocal.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,11 @@ protected function createGroup($attributes, $old = false, $key = null): Group
445445
}
446446
$model = $attributes instanceof Model
447447
? $attributes
448-
: $this->safeCreateModel($this->getModelClassForElements(), $attributes);
448+
: (
449+
null != ($instanceModel = $this->getInstance())
450+
? $this->safeFillModel(clone $instanceModel, $attributes)
451+
: $this->safeCreateModel($this->getModelClassForElements(), $attributes)
452+
);
449453
$group = new Group($model);
450454

451455
if ($this->groupLabel) {

0 commit comments

Comments
 (0)