Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy