Problem/Motivation
In the issue #2825712: The allowed values storage setting of list fields should be required the allowed values storage setting was made a required textarea, but with the introduction of multiple input fields for the allowed values setting in #2521800: List key|label entry field is textarea, which doesn't give guidance towards the expected input only the first input field is a required field which can be deleted with the Remove button and the form can be saved without any allowed values for the list field. This does not satisfy the purpose of the allowed values being required.
Steps to reproduce
- Create any list type field on any entity.
- Delete the
requiredinput field (which is the first row of the table). - Save the field settings with no allowed values.
Proposed resolution
Disable the Remove button when there is a single row in the allowed values storage setting.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3382802
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3382802-disable-the-remove
changes, plain diff MR !4633
Comments
Comment #2
srishtiiee commentedComment #3
lauriiiComment #5
srishtiiee commentedComment #6
kunal.sachdev commentedLooks good 👍. Needs work for two small nits.
Comment #7
kunal.sachdev commentedComment #8
srishtiiee commentedComment #9
marcoliverWorks fine! The test fail seems unrelated.
Marking as RTBC.
Comment #10
ckrinaSetting the button as disabled in this situation is an improvement, already as it is. So +1 for getting this in.
But it would be great if we could come up with a pattern that gives more context/feedback to the user about the "why" that button is disabled. My first thought was using the
titleattribute with something like "Mandatory value not removable". Buttitlewon't show up on hover if the button is disabled, plus I'm not sure it's a right use of it. Maybe, as @lauriii suggested, this could be a nice use of the Tooltip once that's in?Comment #13
lauriiiCommitted 2b9d2a9 and pushed to 11.x. Thanks!