Skip to content

ChoiceType with int values broken #21952

Closed
@mcfedr

Description

@mcfedr
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.2.5

I am using Forms to validate incoming data, and have ChoiceTypes that receive int.

#21267 introduces a change that requires all values to strings. Clearly this breaks stuff.

Example:

->add('days', ChoiceType::class, [
    'choices' => [
        'Mon' => 1,
        'Tue' => 2,
        'Wed' => 3,
        'Thu' => 4,
        'Fri' => 5,
        'Sat' => 6,
        'Sun' => 7,
    ],
    'preferred_choices' => [(int) date('w')],
    'multiple' => true,
    'by_reference' => false,
])

And the submitted data is:

'days' => [1, 2, 3, 4, 5, 6, 0],

I am using forms to handle data coming in as json, using mcfedr/json-form

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions