I'm trying to define some ChoiceType in Symfony 3.0.9 in forms where there are populated with ajax depending on how many options are created dynamical, but then the validation form says that the option selected is not valid.
I define the ChoiceType like this:
->add('position', ChoiceType::class, [
'placeholder' => 'Select position',
'choices' => [],
'attr' => [
'class' => 'form-control choice-position'
],
])
And the error I get is:
Symfony\Component\Validator\ConstraintViolation
Object(Symfony\Component\Form\Form).children[lessonGroups].children[0].children[position] = 1
Caused by:
Symfony\Component\Form\Exception\TransformationFailedException
Unable to reverse value for property path "position": The choice "1" does not exist or is not unique
Caused by:
Symfony\Component\Form\Exception\TransformationFailedException
The choice "1" does not exist or is not unique
I don't know if there's needed any further information.
Thank you!