所以我一直在关注本教程http://drupal.org/node/751826。我采用了以下代码:
<?php
function test_myform(&$form_state) {
// Access log settings:
$options = array('1' => t('Enabled'), '0' => t('Disabled'));
$form['access'] = array(
'#type' => 'fieldset',
'#title' => t('Access log settings'),
'#tree' => TRUE,
);
$form['access']['log'] = array(
'#type' => 'radios',
'#title' => t('Log'),
'#default_value' => variable_get('log', 0),
'#options' => $options,
'#description' => t('The log.'),
);
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
$form['access']['timer'] = array(
'#type' => 'select',
'#title' => t('Discard logs older than'),
'#default_value' => variable_get('timer', 259200),
'#options' => $period,
'#description' => t('The timer.'),
);
// Description
$form['details'] = array(
'#type' => 'fieldset',
'#title' => t('Details'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['details']['description'] = array(
'#type' => 'textarea',
'#title' => t('Describe it'),
'#default_value' => variable_get('description', ''),
'#cols' => 60,
'#rows' => 5,
'#description' => t('Log description.'),
);
$form['details']['admin'] = array(
'#type' => 'checkbox',
'#title' => t('Only admin can view'),
'#default_value' => variable_get('admin', 0),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#maxlength' => 64,
'#description' => t('Enter the name for this group of settings'),
);
$form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}
function test_page() {
return drupal_get_form('test_myform');
}
?>
我将此代码粘贴到我的文本字段中。最后,在 php 关闭标记之前,我调用了函数 test_page 如下
test_page();
保存后出现以下错误。
Warning: Parameter 1 to test_myform() expected to be a reference, value given in drupal_retrieve_form() (line 785 of /var/www/html/includes/form.inc).
Warning: Parameter 1 to test_myform() expected to be a reference, value given in drupal_retrieve_form() (line 785 of /var/www/html/includes/form.inc).
现在我不知道为什么。基本上我要做的是创建一个网络表单并将其本地保存在服务器上。如果你们除了使用 Drupal Form API 之外还有其他想法,欢迎提出建议。
任何帮助将不胜感激。