I have a form where I add missions. One of the elements inside the forms is a multiple checkbox (those who need to be ticked) The problem is that I never used Symfony's checkbox before so I'm a little bit lost. The form displays properly but when I try to submit the form, I get the following error:
Notice: Array to string conversion
Here is my entity (at least the concerned part):
//...
/**
* @ORM\Column(name="typeContrat", type="string")
*/
private $typeContrat;
//....
and here is how I added it into the form builder:
$contrats = array(
'stage' => 'stage',
'stage alterné' => 'stage alterné',
'contrat de professionnalisation' => 'contrat de professionnalisation',
'contrat d\'apprentissage' => 'contrat d\'apprentissage'
);
$builder
//...
->add('typeContrat', ChoiceType::class, array(
'multiple' => true,
'expanded' => true,
'choices' => $contrats,
));
I guess the error comes from the fact that I said "expect a string" but I give him an array instead. So how can do to save whatever the user ticks into my database ?
Thank you in advance
Aucun commentaire:
Enregistrer un commentaire