Closed
Description
Right now when submitting a form, all child forms are first submitted, then the data of these child forms is mapped back into the parent data by the parent form.
Shifting the mapping logic into the child form before POST_SUBMIT would make it possible to access changed state in the parent data in POST_SUBMIT listeners. For example:
$updateOnlinePayment = function (FormEvent $event) {
$form = $event->getForm()->getParent();
$order = $form->getData();
$form->add('paymentMethod', 'choice', array(
'disabled' => !$order->isOnlinePaymentSupported(),
));
}
$builder->get('country')->addEventListener(FormEvents::POST_SET_DATA, $updateOnlinePayment);
$builder->get('country')->addEventListener(FormEvents::POST_SUBMIT, $updateOnlinePayment);
Related to #5807.