-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[cookbook][form][dynamic] DataEvent is deprecated in favor of FormEvent #2463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -424,9 +424,6 @@ Our subscriber would now look like:: | |
*/ | ||
private $om; | ||
|
||
/** | ||
* @param factory FormFactoryInterface | ||
*/ | ||
public function __construct(FormFactoryInterface $factory, ObjectManager $om) | ||
{ | ||
$this->factory = $factory; | ||
|
@@ -435,16 +432,13 @@ Our subscriber would now look like:: | |
|
||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
return array( | ||
FormEvents::PRE_BIND => 'preBind', | ||
FormEvents::PRE_SET_DATA => 'preSetData', | ||
]; | ||
); | ||
} | ||
|
||
/** | ||
* @param event DataEvent | ||
*/ | ||
public function preSetData(DataEvent $event) | ||
public function preSetData(FormEvent $event) | ||
{ | ||
$meetup = $event->getData()->getMeetup(); | ||
|
||
|
@@ -459,7 +453,7 @@ Our subscriber would now look like:: | |
$this->customizeForm($form, $positions); | ||
} | ||
|
||
public function preBind(DataEvent $event) | ||
public function preBind(FormEvent $event) | ||
{ | ||
$data = $event->getData(); | ||
$id = $data['event']; | ||
|
@@ -538,6 +532,6 @@ And this should tie everything together. We can now retrieve our form from the | |
controller, display it to a user, and validate it with the right choice options | ||
set for every possible kind of sport that our users are registering for. | ||
|
||
.. _`DataEvent`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Event/DataEvent.php | ||
.. _`FormEvent`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/FormEvent.php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's better to use api links in the document? (that seems to be usefull for all links in this document though) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is indeed better, so that the link goes to the right version |
||
.. _`FormEvents class`: https://github.com/symfony/Form/blob/master/FormEvents.php | ||
.. _`Form class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the [] syntax is php 5.4 only, as long as we support 5.3 we should not confuse people with examples that don't work for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍