这是 pro drupal 书籍的一个示例。
function annotate_admin_settings() {
$options = node_get_types('names');
$form['annotate_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Users may annotate these content types'),
'#options' => $options,
'#default_value' => variable_get('annotate_node_types', array('page')),
'#description' => t('A text field will be available on these content types to
make user-specific notes.'),
);
return system_settings_form($form);
}
但是形成drupal文档,表单样式的构建器是这样的。
function mymodule_myform($form_state) {
}
函数中有一个参数($form_state),当我应该使用这个参数时。谢谢。
最佳答案
如果您正在寻找 $form 和 $form_state 之间的差异:
$form 是一个包含表单结构的关联数组。它通过诸如 hook_form_alter 之类的调用进行修改以添加字段或执行其他操作。
$form_state 是一个包含表单当前状态的键控数组。确切的状态取决于表单在节点过程中的哪个阶段。通常,它保存将在表单提交时处理的值。
关于drupal ----被 $form_state 参数弄糊涂了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4356972/