Problem/Motivation
When configuring a field that already has data and clicking on the "Field settings" tab, the user gets this alarming error:

However, the error is a lie. You can change anything on the page. The only time you can't is if you change the field cardinality to be less than already-stored values:

This was fixed in #1266748: Changing cardinality lower than highest existing delta causes data loss upon save.
However, the original error message is still wrong, and creates a bad user experience both by making an alarming message and by making the software seem buggy because the message is proven wrong.
Proposed resolution
- Remove the current message.
- Reword the current nonthreateneing message:
These settings apply to the Image field everywhere it is used. These settings impact the way that field data is stored and the defaults that are provided.
- Provide a clearer validation message when the allowed values are reduced below the current values in the field.
Remaining tasks
User interface changes


API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | data-length-disabled.png | 153.45 KB | bnjmnm |
| #22 | message-field-ui-after-patch.png | 80.79 KB | joaopauloc.dev |
| #22 | message-field-ui-before-patch.png | 87.44 KB | joaopauloc.dev |
| #22 | error-message-field-ui-after-patch.png | 91.36 KB | joaopauloc.dev |
| #22 | error-message-field-ui-before-patch.png | 91.4 KB | joaopauloc.dev |
Comments
Comment #2
xjmComment #3
xjmBetter place in the form markup for the description, and a screenshot of the same test as in the summary with the patch applied.
Comment #4
xjmHm, the word "cardinality" does not appear elsewhere in the user interface.
Comment #5
xjmSo come to think of it, we don't really need the description on the allowed values field; we just need a clearer validation error when the user tries to reduce the value too much.
Comment #6
xjmComment #8
xjmJust fixing the test failures, because it's not going to match the period I changed to a comma.
Comment #9
berdirYay!
The issue title is not 100% correct, as it is not just the cardinality that has restrictions, it's basically up to each field type to define that. But the descriptions are accurate and look great to me.
I also can't imagine that we don't already have an issue for this, but maybe we really don't.
And we might want a separate issue to discuss making the upload destination configurable, because right now it's not even though there is IMHO no reason for that, if anything, we could add a description that it will only affect new files and not existing ones. See \Drupal\file\Plugin\Field\FieldType\FileItem::storageSettingsForm()
Comment #21
lauriiiRerolling for 10.1.x
Comment #22
joaopauloc.dev commentedHey.
Tested the patch and works fine.
See attachments for evidence.
Comment #23
xjmThere is unaddressed feedback about a possible followup and/or possibly adding a description that it will only affect new files and not existing ones:
...Or at least that's the only reason I can see that @Berdir did not RTBC this six years ago. :)
IMO that scope could be handled separately. The more help text there is, the worse the UX. The current patch improves the current state significantly, but I'm not sure if other, semi-related additions would or if they belong in the same patch.
Can't commit this as it's my patch to begin with.
Comment #24
larowlanIt would good to see a screenshot here showing what happens if you try to change the length of a text plain field that already has data
Comment #25
bnjmnmCreated #3336188: Consider making file field upload destination changeable even after data exists to preserve the suggestion in #9
OK!
Comment #28
bnjmnmResisted the urge to bikeshed phrasing minutae because this is a very clear improvement over what was very misleading UI experience. This should have happened long ago and nitpicking text can happen in a followup if needed. Lets take care of the blight.
Committed to 10.1.x and cherry-picked to 10.0.x since it is a bugfix and not particularly disruptive.
Comment #29
bnjmnmComment #30
wim leersNice! 🤩
Looking forward to moving this to proper validation constraints next in #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints 🤓