我需要为Drupal 7中的节点添加一个编程式表单。如何将表单附加到节点上?如何以编程方式将表单添加到Drupal 7中的节点?
function addtabexample_form($node, &$form_state) {
$type = node_type_get_type($node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#default_value' => !empty($node->title) ? $node->title : '',
'#required' => TRUE,
'#weight' => -5,
);
$form['field1'] = array(
'#type' => 'textfield',
'#title' => t('Custom field'),
'#default_value' => $node->field1,
'#maxlength' => 127,
);
return $form;
}
这是一个非常方便的片段。谢谢。 – stefgosselin 2014-07-28 20:51:48