You are here

function taxonomy_manager_form_add_submit in Taxonomy Manager 6

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.admin.inc \taxonomy_manager_form_add_submit()
  2. 7 taxonomy_manager.admin.inc \taxonomy_manager_form_add_submit()

Submit handler for adding terms

1 string reference to 'taxonomy_manager_form_add_submit'
taxonomy_manager_add_form in ./taxonomy_manager.admin.inc
form for adding terms

File

./taxonomy_manager.admin.inc, line 789

Code

function taxonomy_manager_form_add_submit($form, &$form_state) {
  $terms = array();
  $selected_tids = array();
  $selected_tids = $form_state['values']['taxonomy']['manager']['tree']['selected_terms'];
  foreach ($form_state['values']['add']['term'] as $value) {
    if (!empty($value)) {
      $terms[] = $value;
    }
  }
  if ($form_state['values']['add']['mass']['mass_add']) {
    foreach (explode("\n", str_replace("\r", '', $form_state['values']['add']['mass']['mass_add'])) as $term) {
      if ($term) {
        $terms[] = $term;
      }
    }
  }
  foreach ($terms as $name) {
    $term = array();
    $term['name'] = $name;
    $term['vid'] = $form_state['values']['vid'];
    $term['parent'] = $selected_tids;
    taxonomy_save_term($term);
  }
  taxonomy_manager_update_voc($form_state['values']['vid'], $selected_tids);
  drupal_set_message("Terms added: " . check_plain(implode(', ', $terms)));
}