Skip to content

Commit b998f86

Browse files
committed
[#2927] Tweaks to form events changes
1 parent ade0d4b commit b998f86

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

cookbook/form/dynamic_form_modification.rst

+9-7
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ the data that was submitted by the user. For example, imagine you have a registr
400400
form for sports gatherings. Some events will allow you to specify your preferred
401401
position on the field. This would be a ``choice`` field for example. However the
402402
possible choices will depend on each sport. Football will have attack, defense,
403-
goalkeeper etc... Baseball will have a pitcher but will not have goalkeeper. You
404-
will need the correct options to be set in order for validation to pass.
403+
goalkeeper etc... Baseball will have a pitcher but will not have a goalkeeper. You
404+
will need the correct options in order for validation to pass.
405405

406406
The meetup is passed as an entity field to the form. So we can access each
407407
sport like this::
@@ -455,11 +455,13 @@ On a form, we can usually listen to the following events:
455455

456456
.. versionadded:: 2.2.6
457457

458+
The behavior of the ``POST_BIND`` changed slightly in 2.2.6, which the
459+
below example uses.
458460

459-
The key is to add a ``POST_BIND`` listener to the field your new field is dependent
460-
on. If you add a POST_BIND listener to a form child, and add new children to the parent
461-
from there, the Form component will detect the new field automatically and maps it
462-
to the client data if it is available.
461+
The key is to add a ``POST_BIND`` listener to the field that your new field
462+
depends on. If you add a ``POST_BIND`` listener to a form child (e.g. ``sport`),
463+
and add new children to the parent form, the Form component will detect the
464+
new field automatically and map it to the submitted client data.
463465
464466
The type would now look like::
465467
@@ -496,7 +498,7 @@ The type would now look like::
496498
}
497499
);
498500
499-
$builder->get('meetup')->addEventListener(
501+
$builder->get('sport')->addEventListener(
500502
FormEvents::POST_BIND,
501503
function(FormEvent $event) use ($formModifier) {
502504
// It's important here to fetch $event->getForm()->getData(), as

0 commit comments

Comments
 (0)