-
Notifications
You must be signed in to change notification settings - Fork 642
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
[4.x]: Dropdown field appears blank even with a default set #13034
Comments
This is working as expected. The default value will only come into play for new entries, where we definitely know that the existing You can bulk-set a specific value on your existing entries using the |
@brandonkelly In my opinion, it makes sense to add an empty option to new dropdown fields with no default value on existing entries to "force" the user to make a decision and select a value. But for new fields with a default value set, this is really annoying. Are you sure that this is intended behaviour? If I understand correctly, the idea in #12235 was to only add this behaviour for new fields on existing entries with no default value set. Of course I could use the resave command or write a simple content migration every time a new dropdown field with a default value is added. But this is just unnecessary work in my opinion and was working as expected before the 4.4 update. I don't mind that existing entries have a null value before they are resaved again - just that it throws an error when not explicitly choosing a value even though there is a default value set. |
@linusschwab The default option has never come into play for existing elements; only brand new ones. |
@brandonkelly Oh, good to know, thanks for the info. Then this just worked in the past because the first option was likely often set as the default value in our case... Then I will either just set the default option as But wouldn't a behaviour like that make sense? Basically to pre-select the default option (if one is set) in the UI for existing entries instead of throwing an error on save. Otherwise there is also no indication to the user which of the options is the default one. |
@linusschwab The tricky thing is that it’s not extremely clear whether a So that’s why we just don’t try to be smart, and only actually use the default value for completely new entries. And give you the |
@brandonkelly Thanks a lot for the detailed answer. I can see your point, especially if the smart behaviour does not work as expected. Personally I still think that this would be less of a problem, at least in our case it happens much more often that a new dropdown field is added than an existing ( It's great to have the console commands, but for more complex scenarios (matrix or super table fields) and to make sure that it gets executed automatically during the deployment, I would still use migrations over them personally. |
Craft 4.5.0 is out with an improvement to Dropdown field behavior: now if a Dropdown field’s value is invalid, and the field contains an explicit Default option, the default option will be auto-selected, and the field will be marked as changed. (#13540) |
What happened?
Description
The default dropdown property is ignored when adding a new dropdown field to an entry. This isn't a huge issue for one-off dropdowns but if you have a matrix/neo field layout, you have to then set all of the defaults manually on the entry.
Steps to reproduce
Expected behavior
The new dropdown field on the entry should have the default applied therefore not requiring a user to make a selection.
Actual behavior
The new dropdown field appears blank and throws a "Field is Invalid" error when a user attempts to save.
Craft CMS version
Craft Pro 4.4.5
PHP version
8.0.8
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Batch Actions 1.3.0
Contact Form 3.0.1
Contact Form Extensions 4.2.2
Control Panel CSS 2.6.0
CP Field Inspect 1.4.4
Embedded Assets 3.1.3
Empty Coalesce 4.0.0
Neo 3.7.5
Quick Field 2.0.3
Redactor 3.0.4
Table Maker 4.0.4
The text was updated successfully, but these errors were encountered: