You are here

function cshs_handler_filter_term_node_tid::value_form in Client-side Hierarchical Select 7

Define the actual exposed form.

Overrides views_handler_filter_term_node_tid::value_form

File

includes/handlers/cshs_handler_filter_term_node_tid.inc, line 54
Definition of cshs_handler_filter_term_node_tid.

Class

cshs_handler_filter_term_node_tid
Filter by term id (including selection by client-side hierarchical select).

Code

function value_form(&$form, &$form_state) {
  global $language;
  parent::value_form($form, $form_state);
  $vocabulary = taxonomy_vocabulary_machine_name_load($this->options['vocabulary']);
  if (empty($vocabulary) && $this->options['limit']) {
    $form['markup'] = array(
      '#markup' => '<div class="form-item">' . t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
    );
    return;
  }
  if ($this->options['type'] == 'cshs' && $this->options['exposed']) {

    // Set the element type to CSHS.
    $form['value']['#type'] = 'cshs';

    // Get the options in a special form.
    $options = _cshs_get_options($this->options['vocabulary']);
    $form['value']['#options'] = $options;

    // Add a "none" option.

    //$form['value']['#options'][CSHS_DEFAULT_NONE_VALUE] = CSHS_DEFAULT_NONE_LABEL;
    _cshs_add_none_option($form['value']['#options']);
    $form['value']['#default_value'] = CSHS_DEFAULT_NONE_VALUE;

    // Set the level labels if defined.
    $labels = array();
    if (isset($this->options['level_labels']) && strlen($this->options['level_labels'])) {
      $labels = drupal_explode_tags($this->options['level_labels']);
    }
    $form['value']['#labels'] = $labels;
  }
  if (empty($form_state['exposed'])) {

    // Retain the helper option.
    $this->helper
      ->options_form($form, $form_state);
  }
}