Skip to content

Commit

Permalink
More correct solution
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Apr 10, 2023
1 parent 9adf80f commit 3e999a9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/EventListener/ResizeFormListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public function preSubmit(FormEvent $event): void

// Add all additional rows
foreach ($data as $name => $value) {
// remove selected elements before adding them again
if (isset($value['_delete'])) {
unset($data[$name]);

continue;
}

// Type cast to string, because Symfony form can returns integer keys
if (!$form->has((string) $name)) {
$buildOptions = [
Expand All @@ -138,11 +145,6 @@ public function preSubmit(FormEvent $event): void

$form->add($name, $this->type, $options);
}

// remove selected elements before adding them again
if (isset($value['_delete'])) {
unset($data[$name]);
}
}

$event->setData($data);
Expand Down

0 comments on commit 3e999a9

Please sign in to comment.