Skip to content

ChoiceType fails when there is null in array submitted #56877

@nikola-jovanovic-php

Description

@nikola-jovanovic-php

Symfony version(s) affected

7.0

Description

Warning: array_flip(): Can only flip string and integer values, entry skipped

How to reproduce

pass null value as an value of ChoiceType that has multiple option set to true (array of values).

{
    "choice": [null, ...]
}

Possible Solution

filter null values from array or convert them to empty string

Additional Context

failing line: https://github.com/symfony/form/blob/7.0/Extension/Core/Type/ChoiceType.php#L125

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