You are here

function event_taxonomy_filter_form in Event 5

Same name and namespace in other branches
  1. 5.2 event.module \event_taxonomy_filter_form()

Builds the taxonomy filter form.

Parameters

$curterm The current term id.:

$autosubmit Adds 'onChange' form submit javascript command to control.:

Return value

An array representing the form.

1 string reference to 'event_taxonomy_filter_form'
_event_get_taxonomy_control in ./event.module
Returns a dropdown event taxonomy term input control.

File

./event.module, line 1664

Code

function event_taxonomy_filter_form($curterm, $autosubmit) {
  $types = event_get_types();
  $vs = array();
  foreach ($types['all'] as $type) {
    $results = taxonomy_get_vocabularies($type);
    foreach ($results as $vocab) {
      $vs[$vocab->vid] = $vocab;
    }
  }
  $results = null;
  foreach ($types['solo'] as $type) {
    $results = taxonomy_get_vocabularies($type);
    foreach ($results as $vocab) {
      $vs[$vocab->vid] = $vocab;
    }
  }
  $items['all'] = t('(all)');
  foreach ($vs as $vid => $vocab) {
    $tree = taxonomy_get_tree($vid);
    foreach ($tree as $term) {
      $items[$term->tid] = $vocab->name . ' - ' . $term->name;
    }
  }
  $form['event_term_select'] = array(
    '#type' => 'select',
    '#default_value' => $curterm,
    '#options' => $items,
    '#description' => t('Select event terms to filter by'),
  );
  if ($autosubmit) {
    $form['event_term_select']['#attributes'] = array(
      'onChange' => 'this.form.submit()',
    );
  }
  return $form;
}