Last active
August 29, 2015 14:23
-
-
Save slivorezka/a794988818139ff36020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function demo_drupal_way_hierarchical_select_form_submit($form, $form_state) { | |
if ($form_state['triggering_element']['#name'] == 'submit') { | |
$term_names = array(); | |
foreach ($form_state['values']['items'] as $tid) { | |
$term = taxonomy_term_load($tid); | |
if (isset($term->name)) { | |
$term_names[] = $term->name; | |
} | |
} | |
drupal_set_message(t('You entered the next location: @loc', array('@loc' => implode(', ', $term_names)))); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function demo_drupal_way_hierarchical_select_form_submit($form, $form_state) { | |
if ($form_state['triggering_element']['#name'] == 'submit') { | |
$term_tids = array(); | |
foreach ($form_state['values']['items'] as $tid) { | |
if (is_numeric($tid)) { | |
$term_tids[] = $tid; | |
} | |
} | |
// Select last value. | |
$last_chosen = end($term_tids); | |
// Redirect to term page. | |
if (!empty($last_chosen)) { | |
drupal_goto('taxonomy/term/' . $last_chosen); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment