A menu item is defined with drupal_get_form
as callback function and returning the form from call back function. How can I add taxonomy_term_reference
field to this form?
$items['files/add'] = array(
'title' => 'Add file',
'description' => 'Allows users to add files',
'type' => MENU_CALLBACK,
'page callback' => 'drupal_get_form',
'page arguments' => array('mymodule_add_file'),
'access callback' => TRUE,
);
function mymodule_add_file($form, &$form_state) {
drupal_set_title("Add file");
$form['mymodule_form'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#collapsable' => FALSE,
'#title' => 'Adding file to locker room',
);
$form['mymodule_form']['file'] = array(
'#type' => 'managed_file',
'#title' => 'Upload file',
);
$form['mymodule_form']['tag'] = array(
'#type' => 'taxonomy_term_reference',
'#title' => 'Tags',
);
return $form;
}
I am not sure how to add taxonomy_term_reference field for $form['mymodule_form']['tag']
. I want this field to be a text field with auto complete from a vocabulary terms and new term to be added when entered term is not found