Skip to content

Dropdown/lookup field shows empty value for required model fields #2026

@DarkSide666

Description

@DarkSide666

If we have model hasOne field , then in form it shows red asterisk near dropdown/lookup field in case required => true is set in model field.
BUT dropdown still contains empty value option in it.
image

I think empty value option should not be there if field is required, then we should force to fill it already in Form. Otherwise if it's left blank in Form and you try to save it will throw big, red exception.


And another related, but opposite issue.
If model field is defined like this

$this->addField('color', [
    'enum' => ['green', 'red', 'blue', 'orange', 'yellow', 'purple', 'gray'],
]);

Then in Form it shows dropdown/lookup field, but there is no empty option in there. Model field is not set as required, so empty option should be available in dropdown. Asterisk do not show too (which is correct).

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