Skip to content

[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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
];
);
Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

/**
* @param event DataEvent
*/
public function preSetData(DataEvent $event)
public function preSetData(FormEvent $event)
{
$meetup = $event->getData()->getMeetup();

Expand All @@ -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'];
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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)

Copy link
Member

Choose a reason for hiding this comment

The 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