-
Notifications
You must be signed in to change notification settings - Fork 639
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
Improve invalid Dropdown value behavior #13540
Improve invalid Dropdown value behavior #13540
Conversation
DEV-1118 Set Dropdown inputs to the default value when invalid
When a Dropdown field’s value is invalid, it should be reassigned to its default value (and marked as changed). |
@northform Could you send your Composer files and a database backup over to support@craftcms.com so we can reproduce and look into it from there? |
I'm running into the same issue as @northform. I am having a hard time putting my finger on exactly what is going on, but I think it has to do with a dropdown field being invalid in two different sites. Craft seems to only "fix" the current site to the default option, but having that invalid value in the other site nevertheless prevents the current site from being saved, so there is no way to update either one of them. |
@elivz Cross site validation behavior is improving in the next release (see #13675 (comment)). Maybe it will solve that for you? |
Sounds like it should, in theory anyway. Right now I have some pages that are stuck in a state where they are impossible to update short of fiddling with the raw data in the DB, so anything will be an improvement! |
Any chance you have time to test in the next few minutes as I’m preparing the release? If so and it turns out to still be a problem for you, I could try to improve it further. If you can, then change your |
Works now for me! On an entry where I was previously stuck in that validation loop between two sites, I am now able to save each site separately, which updates the dropdown fields to their default values. No errors or other issues. Thanks! |
Awesome, thanks so much for checking! |
Description
Improves the behavior of Dropdown fields when their value is invalid.
As of 4.4, invalid Dropdown fields which didn’t have a blank option would get a blank option prepended, and that would be selected by default in the UI (see #12235 (comment)). This would lead to a validation error on save (because a blank value wasn’t one of the allowed options), forcing the author to make a valid selection.
That confused authors because they were getting validation errors for fields they hadn’t even edited.
With this PR, invalid Dropdown fields which have a default option will now automatically select that instead, and the field will immediately be marked at changed, to indicate that the selected option is not equal to the field’s actual current value, until it’s saved.
Related issues