Skip to content

[Form] EnumType: Use the enums value as default label (instead of name) #44596

@ThomasLandauer

Description

@ThomasLandauer

Description

Right now, EnumType uses the enum's name as default <label> for the <input>, see https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Form/Extension/Core/Type/EnumType.php#L34

But since PHP only allows a very limited set of characters for enum names (ASCII, no blanks, etc.), it might be better to use the enum's value by default?

This would be a BC break. If that's not worth it, then maybe a boolean option, e.g. value_as_label?

I know it can be overridden with choice_label (even though that's not documented - see symfony/symfony-docs#16179 (comment)), but since I think this will be a common need in the future, it might be better to offer an easier way.

Example

No response

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