Skip to content

Instantly share code, notes, and snippets.

@ChubV ChubV/FormType.php
Created Nov 29, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.