菜单项定义drupal_get_form
为回调函数,并从回调函数返回表单。如何taxonomy_term_reference
在此表单中添加字段?
$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;
}
我不确定如何为添加taxonomy_term_reference字段$form['mymodule_form']['tag']
。我希望此字段是一个具有自动完成的词汇字段的文本字段,并且当找不到输入的术语时要添加新术语
page
代码末尾在做什么?接缝到我像无效的PHP代码?