Skip to content

[Form][Bug][2.7.8+] Bug when using false as a value in an optional choice field #17292

@ivoaz

Description

@ivoaz

After upgrading from 2.7.7 to 2.7.8 I noticed that some choice fields didn't display the empty value.

Example code:

->add('buyback', 'choice', [
    'choices' => [
        'Yes'  => true,
        'No'   => false,
    ],
    'choices_as_values' => true,
    'required'          => false,
]);

Before:
image
After:
image

So far I've found out that the false value is converted to empty string in this line v2.7.7...v2.7.8#diff-780e59a429c485d2d3b8a37fdf62ac59R79.

I think that the false value is displayed instead of empty value because of that.

This bug was introduced in #16705.

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