Created
November 29, 2012 07:56
-
-
Save ChubV/4167466 to your computer and use it in GitHub Desktop.
Set form values after bind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FormType extends AbstractType | |
{ | |
// .... | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add('field') | |
->add(....) | |
->addEventListener(FormEvents::POST_BIND, array($this, 'postBind')); | |
} | |
public function postBind(FormEvent $e) | |
{ | |
//data is ur entity object here | |
$data = $e->getForm()->getData(); | |
$data->setSomeAdditionalField('someAdditionalData'); | |
} | |
// .... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment