Checkboxes and radios disappear in tableselect

Created on 9 January 2018, almost 7 years ago
Updated 21 June 2024, 4 months ago

Hi! At days I found one bug in this theme. I created custom form with 'tableselect' element and instead of checkboxes in the first column of table I found only empty div's in cells. I dig deeper into this problem and found the following lines in 'includes/form.inc'

function radix_preprocess_form_element(&$variables) {
  // Render the form element inside the label for checkbox and radio.
  if (in_array($variables['element']['#type'], ['checkbox', 'radio'])) {
    $variables['label']['#children'] = $variables['children'];
    unset($variables['children']);
  }
}

This code moves checkbox and radios into the labels. It is OK, but in tableselect we have checkboxes and radios without labels. So if label is invisible, it's children are not rendered too. So I propose the following solution:

if (in_array($variables['element']['#type'], ['checkbox', 'radio']) && $variables['label']['#title_display'] !== 'invisible') {

And here is a patch with this fix.

🐛 Bug report
Status

Closed: outdated

Version

3.0

Component

Code

Created by

🇧🇾Belarus gun_dose

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024