Symfony 3.0.9でいくつかのChoiceTypeを定義しようとしていますが、フォームには動的な作成オプションの数に応じてajaxが設定されていますが、有効です。Symfony ChoiceType空白配列を初期化
私はこのようなChoiceTypeを定義します。
->add('position', ChoiceType::class, [
'placeholder' => 'Select position',
'choices' => [],
'attr' => [
'class' => 'form-control choice-position'
],
])
そして、私が手にエラーがある:
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
任意のより詳細な情報が必要になった場合、私は知りません。
ありがとうございました!
あなたのsymfonyのバージョンは何ですか? – goto
フォームイベントを参照する必要があります - http://symfony.com/doc/current/form/dynamic_form_modification.html – Rooneyl