0
所以我一直在關注本教程http://drupal.org/node/751826。我採取了以下代碼:Drupal窗體API
<?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).
現在我不知道爲什麼。基本上我想要做的是創建一個webform並將其保存在本地服務器上。如果你們除了使用Drupal Form API還有其他想法,歡迎大家提出建議。
任何幫助將不勝感激。
錯誤信息消失了,但是當我保存並轉到他的頁面時,什麼都沒有顯示出來。就好像我甚至沒有調用函數.... –
看一些額外的信息。無法將所有內容發佈在評論中,因此我只編輯了我的原始回覆。我認爲這樣做。如果有效,請繼續並接受答案。 –