我試圖在Drupal 6中創建一個自定義窗體,並且下面的代碼似乎都可以正常工作,包括在數據庫中創建新條目時提交的所有$ form_state值是空的。我錯過了什麼?Drupal 6:form_state值提交時爲空
<?php
function rate_form($form_state) {
$form = array();
$form['rate']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#maxlength' => 100,
'#required' => TRUE,
);
$form['rate']['description'] = array(
'#type' => 'textarea',
'#title' => t('blah, blah'),
'#maxlength' => 1500,
);
$form['rate']['submit'] = array('#type' => 'submit', '#value' => t('Rate!'));
return $form;
}
print drupal_get_form($form_id);
function rate_form_submit($form_id, &$form_state) {
db_query("INSERT INTO {rate_comments} (name, description) VALUES ('%s', '%s')", $form_state['values']['rate']['name'], $form_state['values']['rate']['description']);
drupal_set_message(t('Thank you! Your rating has been added.'));
}
?>
是的,偉大的工作!其實我會在'duh'下面提交這個文件,因爲我不能相信我沒有嘗試過。 ;) – EddyR 2009-09-23 09:35:15
作爲Drupal開發的新手,非常感謝您向我介紹dpm()函數。 – shanet 2012-05-13 04:45:11