diff --git a/Form/SelectionUpdateForm.php b/Form/SelectionUpdateForm.php index c3ac9be..3a978a3 100644 --- a/Form/SelectionUpdateForm.php +++ b/Form/SelectionUpdateForm.php @@ -4,6 +4,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Exception\PropelException; +use Selection\Model\SelectionContainerAssociatedSelectionQuery; use Selection\Model\SelectionContainerQuery; use Selection\Model\SelectionQuery; use Selection\Selection; @@ -129,14 +130,19 @@ function (FormEvent $event) { $data = $event->getData(); $selectionContainerWrongValue = $data['selection_container']; $data['selection_container_id'] = null; - if (null !== $selectionContainerWrongValue) { - $selectionContainerValue = $this->containersArray[$selectionContainerWrongValue]; - $data['selection_container_id'] = $selectionContainerValue; + $selectionContainer = SelectionContainerAssociatedSelectionQuery::create() + ->filterBySelectionId($data['selection_id']) + ->filterBySelectionContainerId($selectionContainerWrongValue) + ->findOne(); + + if (null !== $selectionContainer) { + $data['selection_container_id'] = $selectionContainer->getSelectionContainerId(); } $event->setData($data); } ); + $this->formBuilder->addEventListener( FormEvents::PRE_SET_DATA, function (FormEvent $event) {