Closed
Description
Updating to 2.7 breaks a few of my forms that use choice_list
with an ObjectChoiceList
:
'choice_list' => new ObjectChoiceList($choices, 'label', array(), null, 'value'),
results in:
LogicException in Form.php line 374:
The form's view data is expected to be an instance of class Acme\Model\Choice, but is a(n) string. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) string to an instance of Acme\Model\Choice.
I understand that choice_list
is deprecated, so I've tried using:
'choices' => $choices,
'choices_as_values' => true,
as well as using a DefaultChoiceListFactory
as described in https://github.com/symfony/symfony/blob/2.7/UPGRADE-2.7.md, but I'm not really getting anywhere.
Is there documentation anywhere for how to use objects as choices in 2.7?