Open Sashkan opened 8 years ago
This is not a GenemuFormBundle specific case. If you try your code with the basic choice
type, it normal throw the same warning.
In your case, I asume you do not want to use optgroup
. So you have to give in place of the choices
option, an associative array of key => string
. And stdClass is not a string. If you want to give objects, define the method public function __toString()
in your class (so create one for this and do not use stdClass). In this method, return the string you want to be display in the select input to represente your object.
At this time (maybe in a next release of Symfony), if you want to pass more then just a string, you cannot do that with default choice
form type (same for genemu_jqueryselect2_choice
).
I'm struggling with a genemu_jqueryselect2_choice
in this case, $airports is an array of stdClass objects, which look like this :
This causes an error : Warning: Illegal offset type
How can I use this array as a select2 choice input ?