Skip to content

[Form][2.8] Type "entity" not setting selected data when choice_value is a string attribute #17271

Closed
@Rasanga

Description

@Rasanga

I have the following code:

$builder->add('category', 'entity', [
                'required'      => false,
                'class'         => 'Ras\Bundle\DomainBundle\Entity\Category',
                'choice_value'  => 'name',
                'choice_label'  => 'label'
            ]);

When I select a category it does not give me the selected category entity, but when I changed choice_value to be id it worked fine. There seem to be an issue when the choice_value is a string attribute

NOTE:
Ras\Bundle\DomainBundle\Entity\Category entity has following attributes: id, name, label

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