-
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
[3.7.59]: Editing Dropdown field labels or values with an existing default causes a blank option to display in the list. #12262
Comments
Thanks for reaching out! This is currently working as expected, although I understand how it's not ideal. When you update the values of the dropdown field, the values already in the database aren't affected. That means when you come back to the page, the value of the field getting rendered to the template will be the old To avoid having to migrate all the old values by hand, you can use the
I definitely recommend taking a backup and testing that locally before running anything on production since I'm not able to test against your full data set, but if it's good, you can just repeat that same command with the other values. You could do something similar with a content migration if you're more comfortable with taking that route. I'm closing this for now, but still happy to answer any other questions if you have them. |
Hi Brian! Thanks for getting back to me! Yikes, so we are definitely using this field in 275+ entries in our company's website under many, many different sections. I attempted to start with our
At least in part of the error, I see it's trying to resave the So my follow-up questions are:
I'm curious if the faster solution for now (although a little painstaking) could be to delete this field entirely and recreate it in the component we're using. Thoughts? |
@KettyLezama Whoops, that’s a bug. Setting an invalid field handle should not have bailed the whole command like that. I’ve just fixed that for the next Craft 3 and 4 releases. As you’re on Craft 3, you can pull that fix in a little early by changing your |
@brandonkelly Thank you for fixing that command! I'll give it a try for sure. @brianjhanson @brandonkelly What do you both think about my first follow-up question, by the way? Our company has many, many sections. So am I right in saying that we would need to run this command per every section utilizing that field? Or is there a way to just run it for all sections now that it would just skip the entry if it doesn't have the field? |
@brandonkelly @brianjhanson Also, I am realizing that the command I need to use may be different? It may need to be My dropdown field is within a Matrix Block Type
This command in particular doesn't work, but just showing you my train of thought. Apologies for bugging about my specific question here -- if there is a better forum for this, please do let me know! |
@KettyLezama Correct, if it’s for a Matrix field you should use |
@brandonkelly This: |
It looks like you might have forgotten to update the
|
Craft 3.7.60 and 4.3.2 are out with that fix where |
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
Editing Dropdown field labels or values with an existing default causes a blank option to appear as the first option in the list in an entry that already exists.
This only happens on existing components; if I create a brand new component with this field, the blank value does not show. This doesn't cause problems when a field is optional, but as soon as the field is mandatory, authors are forced to select a value and resave. With so many entries already using this field, you can see how tedious this can be.
Is there a way to avoid this from happening?
Steps to Reproduce
This is how the author sees the field, and this is exactly what I want.
![Old Dropdown](https://user-images.githubusercontent.com/3981398/200016046-180fdf15-0174-42ac-a429-6be11d13662a.png)
This is what the author now sees on existing entry pages that are using this field:
![New Dropdown](https://user-images.githubusercontent.com/3981398/200016664-eb2a6e25-cd11-4ed2-8ba8-533a472d6cdd.png)
Expected Behavior
I would expect the dropdown options to display the same way they were originally -- without a blank option.
Actual Behavior
The first option displayed (and selected) is now blank (null).
Craft CMS version
3.7.59
PHP version
7.4.30
Operating system and version
macOS Monterey 12.6
Database type and version
MySQL 5.7
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: