2012-01-27 39 views
1

该页面的目的是显示作业列表。顶部的表单可让您过滤结果。一旦表单被提交,我想再次显示表单以及放入的值。我将如何在drupal中进行此操作。表单代码如下。如何根据提交的值设置默认值?

function ac_resume_job_list_form($form, &$form_state) 
{ 

    $form['display_options'] = array(
    '#type' => 'fieldset', 
    '#title' => 'Display Options', 
    '#attributes' => array("style" => "width:250px"), 
); 

    $form['display_options']['limit'] = array(
    '#type' => 'textfield', 
    '#title' => 'Limit', 
    '#size' => 2, 
    '#default_value' => 'the value of the submitted form', 
); 

    $form['display_options']['submit'] = array(
    '#type' => 'submit', 
    '#value' => 'Change Display', 
); 


    return $form; 
} 

回答

0

你要设置$form_state['rebuild'] = TRUE形式提交处理程序,基本上在它的重建,你就可以访问所有在形式$form_state变量提交值:

$default_limit = isset($form_state['values']['limit']) ? $form_state['values']['limit'] : 0; // Or whatever default limit you want to have. 

$form['display_options']['limit'] = array(
    '#type' => 'textfield', 
    '#title' => 'Limit', 
    '#size' => 2, 
    '#default_value' => $default_limit 
); 

// Brief example for the submit form 
function my_form_submit($form, &$form_state) { 
    $form_state['rebuild'] = TRUE; 
} 
+0

工作谢谢。 – 2012-01-27 19:37:57