Problem/Motivation
In #2521800: List key|label entry field is textarea, which doesn't give guidance towards the expected input, the form for options field settings was changed, and there is an outer form element with no #type:
$element['allowed_values'] = [
'#element_validate' => [[static::class, 'validateAllowedValues']],
'#field_has_data' => $has_data,
'#allowed_values' => $allowed_values,
'#required' => TRUE,
'#prefix' => '<div id="' . $wrapper_id . '">',
'#suffix' => '</div>',
'#access' => empty($allowed_values_function),
'help_text' => ['#markup' => $this->allowedValuesDescription()],
];
This causes problems.
For example, a 3rd party module can't set #states on it, because the states system expects to find a #type on a form element.
Steps to reproduce
NA
Proposed resolution
Add type container
Remaining tasks
Review
User interface changes
NA
API changes
NA
Data model changes
NA
Release notes snippet
NA
Issue fork drupal-3441061
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:
Comments
Comment #3
smustgrave commentedType container should probably work here right? May be a good novice task.
Comment #4
smustgrave commentedSince it's been a few months just added it.
Doing this as part of my effort to lower my components queue.
Comment #6
smustgrave commentedThis simple?
Comment #7
joachim commentedLGTM.
Comment #8
godotislateQuestion on the MR.
Comment #9
smustgrave commentedApplied suggestion, had to fix a typo but appears to still work.
Comment #10
godotislateFor MR comment.
Comment #11
smustgrave commentedActually didn't know that. But applied.
Comment #12
godotislateI did a manual test to compare the markup for this part of the form:
HEAD:
MR 16154:
Structure is equivalent, and ID generation of the wrapper div is the same. Wrapper div has additional attributes from the
containerelement, but that should be fine.Comment #15
godotislateCommitted and pushed c19d29d to main and 8eacbb0 to 11.x. Thanks!