I am trying to make a multiple-select ChoiceType in my Symfony form. However, I am getting the following error:
Unable to transform value for property path "[organisations]": Expected an array.
Note: If I change the name of the component from organisations to anything else, it's rendering the form correctly.
As far as I can see, organisations is an array:
/**
* @var Organisation[]
* @ORM\ManyToMany(targetEntity="Booking\Entity\Organisation", inversedBy="users")
* @ORM\JoinTable(name="users_organisations")
*/
protected $organisations;
Here's the form:
$organisations = $doctrine->getRepository('Booking\Entity\Organisation')->findAll();
$builder
->add('organisations', ChoiceType::class, array(
'choices' => $organisations,
'choice_label' => function($organisation, $key, $index) {
return $organisation->getName();
},
'multiple' => true
))
What am I doing wrong?
organisationsto anything else, the form is rendered correctlyEntityTypeinstead? It would be simpler.EntityTypedid the trick. Thank you