-1

I needed to have all taxonomy vocabularies available to filter on, without adding all of the taxonomies one at a time.

I did this using the Content: Has taxonomy terms (Multiple) Filter - which renders out as a multiple select list.

I needed to change the select list to checkboxes, but BEF didnt allow me to do that for this type of field, so i did the following...

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == 'views_exposed_form') {

      $options = $form['filter']['#options'];
      unset($form['filter']);

      foreach($options as $vocab => $terms) {

        foreach ($terms as $key => $value) {
            $newkey = $options[$vocab][$key]->option;
            $termoptions[$vocab][key($newkey)] = $newkey[key($newkey)];
        }
        $form[$vocab] = array(
          '#type' => 'checkboxes',
          '#options' => $termoptions[$vocab],
          '#title' => $vocab,
          '#multiple' => TRUE,

        );

      }

  }

}

The exposed form looks good, but it doesnt work.

I think its because the name of the query is wrong. As i have split up the heirarchy into separate fields, the url used to look like

mysite.com/category?filter[]=123

Now it looks like...

mysite.com/category?Brand[123]=123

So theres how far ive got, any ideas how i can make this exposed form work?

I had a poke around at changing the submit handler views_exposed_form_submit but i dont know what i would need to change.

0

Please take a look at https://www.drupal.org/node/2882381 and let me know if the patch in comment #6 meets your needs.

If so, please test that patch and report back the results of your tests in that issue.

Thanks!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.