When there is only one plugin of the type used by the field, the field widget just shows the field label and nothing else. This looks completely broken.
Poking at the code, it looks like what's going on is that the widget sets a value, which doesn't output in the form:
$element['select']['container']['plugin_id'] = array(
'#type' => 'value',
'#value' => $this->getSelectedPlugin()->getPluginId(),
);
This is bad on two counts:
a) it's really bad UX to show something that looks broken. If there is only one option that must be selected, show it and disable the form element
b) it's NOT the only option anyway, as if the field is not required the user could select nothing.
Comments
Comment #2
joachim commentedI think the special handling for a single plugin should just be removed. Options fields in core don't hide themselves when there is only one option: they show either:
or
It could be there's some special voodoo going on to do with the plugin form... but in the absence of code docs explaining that, I'm going to assume there isn't any.
Let's see what the test bot says!
Comment #4
lammensj commentedUpdated the patch for version 8.x-2.7.
Comment #6
lukasss commentedI confirm this!
It's just confusing...
Comment #7
ckaotikThis behavior is - in theory - configurable. However, it's not yet exposed anywhere, see #2822336: Plugin selector field widget configuration.