getCheckedCheckboxes example

/** * Determines if all checkboxes in a set are unchecked. * * @param array $input * An array returned by the FormAPI for a set of checkboxes. * * @return bool * TRUE if all options are unchecked. FALSE otherwise. */
  public static function detectEmptyCheckboxes(array $input) {
    return empty(static::getCheckedCheckboxes($input));
  }

}
$exclude = ['submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset'];
    /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */
    $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form');
    $exposed_form_plugin->exposedFormSubmit($form$form_state$exclude);
    foreach ($values as $key => $value) {
      if (!empty($key) && !in_array($key$exclude)) {
        if (is_array($value)) {
          // Handle checkboxes, we only want to include the checked options.           // @todo revisit the need for this when           // https://www.drupal.org/node/342316 is resolved.           $checked = Checkboxes::getCheckedCheckboxes($value);
          foreach ($checked as $option_id) {
            $view->exposed_raw_input[$key][$option_id] = $value[$option_id];
          }
        }
        else {
          $view->exposed_raw_input[$key] = $value;
        }
      }
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.