php - Symfony select by defaut various options -
i'm working in form symfony , in select want have, default, options selected.
i've try:
->add('idgroupe', choicetype::class, array('label' => 'groupes', 'attr' => array('expanded'=> false, 'data'=>$g, 'multiple'=>'true', 'class' => 'form-control' ), 'choices' => $groupes ) )
where $g array like:
array(1) { [0]=> string(18) "vue1",[1]=> string(18) "vue2" }
but i've got error:
an exception has been thrown during rendering of template ("notice: array string conversion")
try with:
->add('idgroupe', choicetype::class, array('label' => 'groupes', 'attr' => array('class' => 'form-control' ), 'expanded'=> false, 'data'=>$g, 'multiple'=>true, 'choices' => $groupes ) );
Comments
Post a Comment