labels related to checkboxed should be associated to them. i just came across this when clicking on the "Select all items on this page" label didn't mark the checkbox as selected.

if possible we would need a unique id for the checkbox and set the "for" attribute of the label accordingly.
another option is to put the checkbox inside the label element.

#3 select all form kpr.png102.87 KBtexas-bronius
Members fund testing for the Drupal project. Drupal Association Learn more


bojanz’s picture

Category: feature » bug

I'm not actually doing anything special here:

    $form['select_all'] = array(
      '#type' => 'fieldset',
      '#attributes' => array('class' => array('vbo-fieldset-select-all')),
    $form['select_all']['this_page'] = array(
      '#type' => 'checkbox',
      '#title' => t('Select all items on this page'),
      '#default_value' => '',
      '#attributes' => array('class' => array('vbo-select-this-page')),

    if ($enable_select_all_pages) {
      $form['select_all']['or'] = array(
        '#type' => 'markup',
        '#markup' => '<em>OR</em>',
      $form['select_all']['all_pages'] = array(
        '#type' => 'checkbox',
        '#title' => t('Select all items on all pages'),
        '#default_value' => '',
        '#attributes' => array('class' => array('vbo-select-all-pages')),

So the question is: why does it fail...

liquidcms’s picture

i think somewhat related. i have a grid layout and i get a select all on this page checkbox and a select all on all pages checkbox with an OR between them.

to start with, the view is not set to use paging; so silly to have both checkboxes as they are now technically the same thing; but regardless of that, if there was some wort of id or class assigned to a wrapper around the checkboxes, labels and even the OR, it would be possible in css to hide these.

i looked at a form_alter but not available at that time to alter; looking next at after_submit function; failing that i guess only solution is use JS or to write a patch to add some way that css can simply hide these.

texas-bronius’s picture

102.87 KB

It's a good question, if the above code is producing the Select All (Pages) checkboxes. However, the derivative markup that is on the VBO form I am dealing with appears to a) be from a FAPI #markup element and b) not show when Javascript is disabled. Here's the dpm/kpr out of $form in a hook_views_bulk_operations_form_alter:
Screenshot of $form kpr
Something else is going on.

texas-bronius’s picture

Title: "Select all items on this page" label should have for attribute » Click on "Select all items on this page" checkbox label does not affect checkbox: missing "for" html attribute

But in the meantime, from the desk drawers labeled "Don't work around it like this," you can work around like this:

 * Implements hook_views_bulk_operations_form_alter().
 * @param type $form
 * @param type $form_state
 * @param type $vbo
function vbo_single_serve_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if ($form_state['step'] == 'views_form_views_form') {
    // Alter the first step of the VBO form (the selection page).
    $selectallmarkup = $form['select_all_markup']['#markup'];
    $selectallmarkup = str_replace('<input class="vbo-select-this-page form-checkbox"', '<input class="vbo-select-this-page form-checkbox" id="vbo-select-this-page"', $selectallmarkup);
    $selectallmarkup = str_replace('<input class="vbo-select-all form-checkbox"', '<input class="vbo-select-all form-checkbox" id="vbo-select-all"', $selectallmarkup);
    $selectallmarkup = preg_replace('/<label class="option">/', '<label class="option" for="vbo-select-this-page">', $selectallmarkup, 1);
    $selectallmarkup = preg_replace('/<label class="option">/', '<label class="option" for="vbo-select-all">', $selectallmarkup, 1);
    $form['select_all_markup']['#markup'] = $selectallmarkup;

Rough and tumble, toil and bumble..

madhaze’s picture

It seems like all form items should have an id and checkboxes should have a with the for="xxx" (xxx being the inputs id) Due to VBO not using this standard format i'm having issues styling forms to look consistent. I might look to do what is mentioned above as a work around. That or find a js option possibly