Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ObjectChoiceList with 2.7 #16561

Copy link
Copy link
Closed
Closed
Copy link
@rcwsr

Description

@rcwsr
Issue body actions

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.