Skip to content

Instantly share code, notes, and snippets.

@ChubV
Created November 29, 2012 07:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChubV/4167466 to your computer and use it in GitHub Desktop.
Save ChubV/4167466 to your computer and use it in GitHub Desktop.
Set form values after bind
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