Reputation: 33
This has been boggling my mind for hours now, I am using Symfony2's form builder!
->add('technicians', 'choice', array(
'choices' => array(
1 => 'Test'
),
'multiple' => true,
'data' => array(
1 => true
)
))
Image below:
https://i.sstatic.net/aUi7H.png
But when I use Strings as keys in the array, it magically stops working.
Like so:
->add('technicians', 'choice', array(
'choices' => array(
'example' => 'Example'
),
'multiple' => true,
'data' => array(
'example' => true
)
))
https://i.sstatic.net/nB1pi.png
Upvotes: 1
Views: 1690
Reputation: 580
It works with:
->add('technicians', 'choice', array(
'choices' => array(
'example' => 'Example'
),
'multiple' => true,
'data' => array(
'example' => 'example'
),
))
The value for data
should match the key of the choices
array.
true == 1
, that's why your first example was working.
Upvotes: 6