我讀過Drupal API表單文檔,但有些東西我只是沒有得到。
這可能很簡單,但我無法找到如何顯示錶單提交後提交的值。Drupal表單API - 提交時顯示錶單值
*編輯的代碼
<?php
function createForm_enigmaFilters($form_state) {
$form = array();
$form['#submit'][] = 'createForm_enigmaFilters_submit';
$form['list'] = array(
'#type' => 'markup',
'#prefix' => '<ul id="enigmaFilters">',
'#suffix' => '</ul>',
);
$form['list']['startDate'] = array(
'#id' => 'txtStartDate',
'#weight' => '0',
'#type' => 'textfield',
'#size' => '20',
'#title' => 'Date de début',
'#prefix' => '<li>',
'#suffix' => '</li>',
);
$form['list']['endDate'] = array(
'#id' => 'txtEndDate',
'#weight' => '1',
'#type' => 'textfield',
'#size' => '20',
'#title' => 'Date de fin',
'#prefix' => '<li>',
'#suffix' => '</li>',
);
$form['list']['enigmaName'] = array(
'#id' => 'txtEnigmaTitle',
'#weight' => '2',
'#type' => 'textfield',
'#size' => '100',
'#title' => 'Nom des énigmes',
'#prefix' => '<li>',
'#suffix' => '</li>',
);
$form['list']['lstAnswers'] = array(
'#id' => 'lstAnswers',
'#weight' => '3',
'#default_value' => 'Uniquement les bonnes',
'#key_type' => 'associative',
'#type' => 'select',
'#options' => array(
'Toutes les réponses' => 'Toutes les réponses',
'Uniquement les bonnes' => 'Uniquement les bonnes',
),
'#multiple_toggle' => '1',
'#title' => 'Réponses',
'#prefix' => '<li>',
'#suffix' => '</li>',
);
$form['list']['promotionYear'] = array(
'#id' => 'txtPromotionYear',
'#weight' => '4',
'#type' => 'textfield',
'#size' => '40',
'#title' => 'Année de promotion',
'#prefix' => '<li>',
'#suffix' => '</li>',
);
$form['list']['submit'] = array(
'#id' => 'lnkApplyFilters',
'#weight' => '5',
'#type' => 'submit',
'#value' => t('Rechercher'),
'#prefix' => '<li>',
'#suffix' => '</li>',
);
return $form;
}
function createForm_enigmaFilters_submit($form, &$form_state) {
echo $form_state['values']['startDate'];
echo $form_state['values']['endDate'];
echo $form_state['values']['enigmaName'];
echo $form_state['values']['lstAnswers'];
echo $form_state['values']['promotionYear'];
}
echo drupal_get_form('createForm_enigmaFilters');
?>
你的輸出是什麼?嘗試使用print_r($ myform)。 – hummingBird 2010-11-06 16:27:15