Closed briancwald closed 7 years ago
I'm realizing this is also an issue if a module uses a checkbox that is NOT getting the forms API wrapper (and no label) (I.E. Hardcoded checkboxes). I guess I will need a method to add labels to those too. Ideas on how to handle this?
Features UI ALSO does this for the bulk selection checkbox.
Ideas on how to handle this?
Maybe in that case you get the default browser checkbox, as an incentive to use Form API? I think that a Drupal theme should be safe to assume the use of Form API for form elements.
The only other alternative I can think of, for hard-coded checkboxes, is to use JS after page load to append empty labels.
yeah I could try something like this, but its pretty nasty...
if(this.sibling.nodeName != 'label') {
$(this).after('<label for="'+this.id+'"></label>')
}
})
This method doesnt seem to cause weird behavior or 'duplicate' checkboxes in various areas so I dont think this solution works.
Another case of this coming up, this time in core: https://www.drupal.org/node/2897139
I think I can address the ones coming from FormAPI because I added a 'no-label' if it doesnt have anything in the container.
title_display not in ['after', 'before'] ? 'form-no-label',
Materializecss requires a label for it to transform the checkbox correctly. If It comes through forms API and no label is present, you just won't see the checkbox at all. This adds a blank label if there is none to avoid checkboxes not showing up.
For examples, Features_ui module does not provide a label (for some reason?) to download an archive of the feature. without this update, you see no checkbox.