Is it possible to disable backend (server-side) validation for the specified field?
Wnen Im trying to send form with dynamicly loaded options I get error "ERROR: This value is not valid."
I think symfony is checking if my value is on the default declared list (in my case its empty list), if not returns false.
It's confusing but this behaviour is not really validation related as it is caused by the "ChoiceToValueTransformer" which indeed searches for entries in your pre-declared list. If your list is empty or you want to disable the transformer you can simply reset it.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('yourField', 'choice', array('required'=>false));
//more fields...
$builder->get('yourField')->resetViewTransformers();
}
Then your custom defined validation will step in (if it exists).
I found the solution
Symfony2.4 form 'This form should not contain extra fields' error
For more details: http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html#cookbook-dynamic-form-modification-suppressing-form-validation
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