The option element that is generated by a #key_select has no 'empty' option.

Besides making the 'key' value implicitly required (which I'm sure is inadvertent)... this preselects the first key in the list, on all edit screens. That (saving an unintended key value) can be dangerous, if the person editing the $thing is not paying close attention.

Fix is simple.

Comments

roderik created an issue. See original summary.

roderik’s picture

StatusFileSize
new458 bytes

Hm, maybe it's just my own lack of recent experience creating Drupal edit screens. (I'm from old times where a #select option had the first option in the select list added as '' => t('- Select -').)

I only now realize that all I have to do is add #empty_option to the element myself.

Still, IMHO this is a good thing for the module to do by default, because as said in the description; an edit screen for a new $thing shouldn't pre-select the first key in the list.

And here's a fixed patch.

rlhawk’s picture

Status: Needs review » Reviewed & tested by the community

I agree completely. Thanks for the patch.

  • fda1d3a committed on 8.x-1.x
    Issue #3215806 by roderik, rlhawk: #key_select elements cannot be empty
    
rlhawk’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.