1

I am getting the following notice on the views edit page:

  • Notice: Undefined index: l12agno in accept_exposed_input() (line 1273 of C:\xampp\htdocs\drupal7\sites\all\modules\views\handlers\views_handler_filter.inc).

  • Notice: Undefined property: views_display::$handler in execute() (line 1134 of C:\xampp\htdocs\drupal7\sites\all\modules\views\includes\view.inc).

I have added a filter on a taxonomy term for which I have written a custom filter handler (by using _views_data_alter):

$data['taxonomy_term_data']['l12agno'] = array(
    'title' => t('L1/2 Agnostic'),
    'help' => t('Lx Agnostic filter'),
    'real field' => 'tid',
    'filter' => array(
      'handler' => 'views_handler_filter_lx_agnostic',
    ),
  );

the custom handler looks like this: here "categoryta" is a 3 level hierarchy.

class views_handler_filter_lx_agnostic extends views_handler_filter {

  function value_form(&$form, &$form_state) {
    parent::value_form($form, $form_state);
    if (!empty($form_state['exposed'])) {
      $form['value'] = array(
        '#type' => 'container',
        '#prefix' => '<div id="views_category_wrapper" class="clear-block container-inline">',
        '#suffix' => '</div>',
        '#tree' => TRUE,
      );
      $vocab = taxonomy_vocabulary_get_names();
      $tree = taxonomy_get_tree($vocab['categoryta']->vid, 0, NULL, TRUE);
      $options = array();
      foreach ($tree as $item) {
        if(!$item->deleted) {
          $options[$item->parents[0]][$item->tid] = $item->name;
        }
      }
      $form['value']['t0'] = array(
        '#type' => 'select',
        '#options' => isset($options[0])? $options[0] : array(),
        '#empty_value' => 0,
        '#empty_option' => t('All'),
        '#default_value' => 0,
      );
      if (isset($options[0])) {
        foreach ($options[0] as $tid => $title) {
          $form['value']['t' . $tid] = array(
            '#type' => 'select',
            '#options' => $options[$tid],
            '#empty_value' => 0,
            '#empty_option' => t('All'),
            '#default_value' => 0,
            '#states' => array(
              'visible' => array(
                ':input[name="l12agno[t0]"]' => array(
                  'visible' => TRUE,
                  'value' => $tid,
                )
              )
            )
          );
        }
      }
    }
  }

  function query() {
    $this->ensure_my_table();
    if (!empty($this->value[0]['t0'])) {
      $t0 = 't' . $this->value[0]['t0'];
      if(!empty($this->value[0][$t0])) {
        $field = "$this->table_alias.$this->real_field";
        $this->query->add_where($this->options['group'], $field, $this->value[0][$t0], '=');
      }
      else {
        $def = $this->definition;
        $def['table'] = 'taxonomy_term_hierarchy';
        if (!empty($this->table_alias)) {
          $def['left_table'] = $this->table_alias;
        }
        else {
          $def['left_table'] = $this->table;
        }
        $def['left_field'] = $this->real_field;
        $def['field'] = 'tid';

        $join = new views_join();

        $join->definition = $def;
        $join->construct();
        $join->adjusted = TRUE;

        // use a short alias for this:
        $alias = $def['table'] . '_' . $this->table;

        $this->alias = $this->query->add_relationship($alias, $join, $alias . '_' . $this->real_field, $this->relationship);
        $this->query->add_where($this->options['group'], "$this->alias.parent", $this->value[0]['t0'], '=');
      }
    }
  }

  public function operators() {
    return array();
  }
}

The same code is working on production, but not in my local system. I have tried flushing cache and trying different browsers and switching between different jquery_update versions. Any help is appreciated.

2
  • Known bug; drupal.org/node/2447227
    – niksmac
    May 26, 2015 at 6:56
  • 1
    @NikhilM i just checked the registry table for path entry for class: views_handler_filter_lx_agnostic and it was missing, adding an entry there solved my problem, but i am still not sure why the entry got removed from the table in the first place.
    – dresh
    May 26, 2015 at 8:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.