Skip to content

getFieldValues() default value instead of null #704

Open
@rudiedirkx

Description

@rudiedirkx

Give fields and field types a default value for 'no value submitted'. getFieldValues() returns null or not at all, but that's imperfect sometimes. 0 checkboxes checked should give an empty array, not null.

class FormField {
    protected mixed $nullValue = null;
}

class CollectionType {
    protected mixed $nullValue = [];
}

$this->add('optional_hobbies', 'checkboxes', [
    'null_value' => [],
]);

or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions