I have a taxonomy vocabulary named "jenis dokumen". I want to let anonymous users add terms within this vocabulary. I'm trying to add a block and render that form to add new term using PHP filter, but it's failing.

This is my code:

include_once(drupal_get_path('module','taxonomy') . '/taxonomy.admin.inc' );
return drupal_render(drupal_get_form('taxonomy_form_term', jenis_dokumen));

Can anyone help?

now i have success with this.

$vocabulary = taxonomy_vocabulary_load(2, FALSE);
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
return drupal_render(drupal_get_form('taxonomy_form_term', $vocabulary));

but, there is a default value in field name 'Jenis Dokumen' how can i get blank (no value) in field?

1 Answer 1


A couple things:

  • The function taxonomy_form_term() expects the $vocabulary parameter to be an object with a "machine_name" property
  • You should wrap the vocab name in quotes
  • More elegant to use module_load_include() instead of include_once()


if ($vocabulary = taxonomy_vocabulary_machine_name_load('jenis_dokumen')) {
  module_load_include('inc', 'taxonomy', 'taxonomy.admin');
  $edit = array();
  $taxonomy_form = drupal_get_form('taxonomy_form_term', $edit ,$vocabulary);
  return drupal_render($taxonomy_form);
  • 3
    +1 you could go one step further and use taxonomy_vocabulary_machine_name_load() to load up the full vocab before passing it through
    – Clive
    Nov 16, 2012 at 15:28
  • i implement your code, now i have an error message like this. Notice: Undefined index: taxonomy_form_term in drupal_retrieve_form() (line 765 of E:\www\for-roni\includes\form.inc). Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'taxonomy_form_term' not found or invalid function name in drupal_retrieve_form() (line 800 of E:\www\for-roni\includes\form.inc).
    – DE51GN
    Nov 17, 2012 at 2:21
  • @Clive nice call, I've updated my answer! :)
    – Alex Weber
    Nov 19, 2012 at 18:03
  • @DE51GN please try again with the updated answer, just copy and paste it to avoid typos plz.
    – Alex Weber
    Nov 19, 2012 at 18:04
  • thank for helping me Alex. i'm still get error message with your code.
    – DE51GN
    Nov 20, 2012 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.