Skip to content

Commit 8abb85b

Browse files
committed
Fix data of the last edited collection entry being used as the default for the new entries
1 parent 6dcf61e commit 8abb85b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Bridge/Interaction/CollectionInteractor.php

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public function interactWith(
6464

6565
$submittedData = [];
6666
$prototype = $form->getConfig()->getAttribute('prototype');
67+
$originalData = $prototype->getData();
68+
6769
$askIfEntryNeedsToBeSubmitted = function ($entryNumber) use ($helperSet, $input, $output) {
6870
return $this->askIfExistingEntryShouldBeAdded($helperSet, $input, $output, $entryNumber);
6971
};
@@ -79,6 +81,8 @@ public function interactWith(
7981
}
8082

8183
if ($form->getConfig()->getOption('allow_add')) {
84+
// reset the prototype
85+
$prototype->setData($originalData);
8286
$key = count($submittedData) - 1;
8387
while ($this->askIfContinueToAdd($helperSet, $input, $output)) {
8488
$this->printAddEntryHeader(++$key, $output);

0 commit comments

Comments
 (0)