Skip to content

[Form] Cast on choice type #11849

Closed
Closed
@peterrehm

Description

@peterrehm

I have a numeric choice type in my application.

$builder
        ->add('test', 'choice', array('choices' => array('1' => 1, '0.9' => 0.9));

The property test is of type float.

Since the Form component populates on every submit the property test with '0.9' (string)
but in the entity there was 0.9 (float) doctrine detects the change and updates the entity
even though this is not necessary.

What do you think about a option to the choice field to cast to integer or float? I see several
use cases where this makes sense and I think in a lot of applications such updates are executed
without any notice.

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