私はsymfonyでフォームで作業しています。選択したものでは、デフォルトでいくつかのオプションを選択したいと思っています。symfony defautによってさまざまなオプションを選択してください
私が試してきました:
$ gはのような配列である->add('idgroupe',
ChoiceType::class,
array('label' => 'Groupes',
'attr' => array('expanded'=> false,
'data'=>$g,
'multiple'=>'true',
'class' => 'form-control'
),
'choices' => $groupes
)
)
:
array(1) { [0]=> string(18) "Vue1",[1]=> string(18) "Vue2" }
しかし、私はこのエラーを持っている:
An exception has been thrown during the rendering of a template ("Notice: Array to string conversion")
'expanded'、' multiple'と 'data'はoptions配列の' attr'部分にあるのではなく、 'attr'自身と同じレベルにあるべきです。 '' true '!== true'(引用符を削除する)。 – Yoshi