2

I load a taxonomy term in the edit form via the following code:

module_load_include ( 'inc', 'taxonomy', 'taxonomy.admin' );
$vocabulary = taxonomy_term_load ( $tid );
$form = drupal_get_form ( 'taxonomy_form_term', $vocabulary );

The vocabulary has a custom text field with unlimited values, so this appears on the form, but when I click the "add another item" button, I get:

Call to undefined function, taxonomy_form_term_validate() in [truncated path].../form.inc" on line 1513.

enter image description here

I appreciate any guidance I can get in solving this.

  • 2
    Where do make the ajax? It can be the case that you are not bootstrapping the necessary files in the ajax. – Potney Switters May 18 '15 at 14:09
  • Potney, this is just the "add another item" button that appears under a field that's set to have unlimited values. – Jav May 19 '15 at 15:41
0

This function worked for me: Please try to use form_load_include() and drupal_build_form() instead of drupal_get_form() to generate form

  $form_id = 'taxonomy_form_term';
  $vocabulary = taxonomy_vocabulary_load($tid);

  $form_state = array();
  $form_state['build_info']['args'] = array($vocabulary);

  // use form_load_include() and drupal_build_form() instead of drupal_get_form()
  form_load_include($form_state, 'inc', 'taxonomy', 'taxonomy.admin');

  $form = drupal_build_form($form_id, $form_state);
  • Shouldn't it be $term = taxonomy_term_load($tid); $form_state['build_info']['args'] = array($term);? – har-wradim Nov 18 '15 at 11:29

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.