This would be really useful and could reduce effort and code required for issues like #6355 and #5489.
Before:
$header = array(
'title' => t('Title'),
'description' => t('Description'),
);
...
// Custom code to add the "for" attribute to the elements that are
// to serve as labels for the checkboxes.
$checkbox_id = backdrop_html_class('edit-name-fields-' . $key);
$fields[$key]['title'] = array(
'data' => '<label for="' . $checkbox_id . '">' . $field['title'] . '</label>',
'class' => array('title'),
);
...
$form['nodes'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No content available.'),
);
After - no custom code required for the for attribute - the Form API makes things work automagically via a new #labels_column attribute (final name TBD):
$form['nodes'] = array(
'#type' => 'tableselect',
'#header' => $header,
// Add (optional) support for something like this:
'#labels_column' => 'title',
// 'title' should be a key that exists in the #header array.
'#options' => $options,
'#empty' => t('No content available.'),
);
This would be really useful and could reduce effort and code required for issues like #6355 and #5489.
Before:
After - no custom code required for the
for
attribute - the Form API makes things work automagically via a new#labels_column
attribute (final name TBD):