我有我的網頁上的數據庫(mytheme_page_preprocess函數中的數據庫的幾個查詢)的一些輸出數據,我想做搜索表單(文本字段和提交按鈕)。那麼,我如何才能在預處理函數中獲取表單提交的值?如何獲取表單中提交的值在page_preprocess函數在drupal 7
類似於在myform_form_submit($ form,$ form_state)中的$form_state['values']
,但在預處理函數中。
我簡單的搜索
function reestr_form($form, &$form_state)
{
$form = array();
$form['q'] = array(
'#type' => 'textfield',
'#size' => 30,
'#default_value' => t(''),
);
$form['submit'] = array(
'#type' => 'submit',
//'#value' => 'send',
'#name' => 'op',
'#src' => base_path() . path_to_theme() . '/images/search-button.png',
'#submit' => array('reestr_form_submit')
);
//$form['#submit'][] = 'reestr_search_submit';
return $form;
}
function reestr_form_submit($form, &$form_values)
{
$message = 'You have submitted the ' . $form_id . ' form which contains the following data:<pre>' . print_r($form_values, true) . '</pre>';
var_dump($message);
}
感謝邁克,是的,我認爲它,但如何提交GET乾淨的網址?我的意思是URL像'http://example.com/node/11?search = smth'? – inJakuzi
像這樣:http://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7#method –