Skip to content

Add uses and fix typo in Dynamic Form Cookbook entry #2909

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 2 commits 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
10 changes: 8 additions & 2 deletions cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ The meetup is passed as an entity hidden field to the form. So we can access eac
sport like this::

// src/Acme/DemoBundle/Form/Type/SportMeetupType.php
namespace Acme\DemoBundle\Form\Type;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

Copy link
Member

Choose a reason for hiding this comment

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

I'd swap these two lines to sort the classes alphabetically.

class SportMeetupType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
Expand All @@ -419,7 +425,7 @@ sport like this::

$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function(FormEvent $event) use($factory){
function(FormEvent $event) use ($factory){
$form = $event->getForm();

// this would be your entity, i.e. SportMeetup
Expand Down Expand Up @@ -532,7 +538,7 @@ The subscriber would now look like::
->find($id);

if ($meetup === null) {
$msg = 'The event %s could not be found for you registration';
$msg = 'The event %s could not be found for your registration';
throw new \Exception(sprintf($msg, $id));
}
$form = $event->getForm();
Expand Down