Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DarkSide666 opened this issue Mar 30, 2023 · 1 comment · May be fixed by #2209
Open

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

DarkSide666 opened this issue Mar 30, 2023 · 1 comment · May be fixed by #2209
Labels

Comments

@DarkSide666
Copy link
Member

DarkSide666 commented Mar 30, 2023

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).

@mvorisek
Copy link
Member

mvorisek commented May 20, 2023

In general, we want to allow field to be unset even if not nullable/required. This is important for UX when user does not have data ATM and simply does not want to select anything. Like when field is required and can be emptied...

Some clear icon would be however probably better than an empty option. Fomantic-UI has a native support - https://fomantic-ui.com/modules/dropdown.html#clearable-selection

related with #572

@mvorisek mvorisek linked a pull request Jun 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants