You are here

function devel_generate_term_form_submit in Devel 7

FormAPI submission to generate taxonomy terms.

File

devel_generate/devel_generate.module, line 337

Code

function devel_generate_term_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  module_load_include('inc', 'devel_generate');
  if ($values['kill_taxonomy']) {
    foreach ($values['vids'] as $vid) {
      devel_generate_delete_vocabulary_terms($vid);
    }
    drupal_set_message(t('Deleted existing terms.'));
  }
  $vocabs = taxonomy_vocabulary_load_multiple($values['vids']);
  $new_terms = devel_generate_terms($values['num_terms'], $vocabs, $values['title_length']);
  if (!empty($new_terms)) {
    drupal_set_message(t('Created the following new terms: !terms', array(
      '!terms' => implode(', ', $new_terms),
    )));
  }
}