Question

I'm working on a Symfony2 project where I have three fields that are populated dynamically which mean are built by AJAX call made in Angular JS controller. So the problem is, when I send the form I get the message:

This value is not valid.

So after do a lot of research (Symfony2 Nested Select in Spanish, Dynamic Form Modification from Symfony2 Docs, How to use Data Transformers from Symfony2 Docs, Post here in Stackoverflow, Entity as hidden field and many more pages I read) I found "almost" nothing so here is my question: what is a "norm data" for a choice field type? This is what my Type returns:

public function getParent() {
    return 'choice';
}

public function getName() {
    return 'country_choice';
}

For some reason the validation fails all the time and I suspect is due to choice type and since I don't know what "norm data" is for a choice type I can't work in proper way on DataTransformer. Could any point me in the right direction? Any advice or help?

Was it helpful?

Solution

I think it depends on the choices you set. For example, if you have a field called 'my_field' with choices:

'choices' => array('m' => 'Male', 'f' => 'Female')

and you set the post data with value 0, the field will be invalid because its value is not in the choices list.

http://symfony.com/doc/current/reference/forms/types/choice.html#choices

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top