I'm working on a symfony2 backend for a backbone.js application. I have my model and form.
However, backbone.js sends some additional properties to the REST API when it's creating/updating a model and I'm struggling to get the form to validate.
How can I get a form in symfony2 to accept additional data, or how can I drop particular keys before binding data to a form?
You should use option "allow_extra_fields".
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(
array(
'allow_extra_fields' => true
)
);
}
For symfony 2.8+ use configureOptions(OptionsResolver $resolver) instead of setDefaultOptions(OptionsResolverInterface $resolver)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With