2011-11-25 26 views
1

我有一個表格A和B形Drupal 7的鍊形成一個

我想作形式的用戶重定向到形成B AND告知形式的

做出的選擇的B型A型的提交功能(不工作):

function recruitment_select_team_submit($form, &$form_state) 
{ 
    // Forward to the next page. 
    $items['yourmod/foo/%/delete'] = array(
    'title' => 'goto next page', 
    'page callback' => 'drupal_get_form', 
    'page arguments' => array('recruitment_form', 1), // second argument is the paramter for the team_id (test value) 
    //'access arguments' => array('delete foo rows'), 
    'access callback' => TRUE, 
    'type' => MENU_CALLBACK, 
    ); 

    return $items; 
} 

表格B的形式:

function recruitment_form() 
{ 
    $team_id = 1; 
    if(db_query('select count(*) from gm_team where id = :team_id',array(':team_id' => $team_id))->fetchfield() == 0) 
    { 
     die('Sorry but the team with team ID '.$team_id.' does not exist. If you feel this is a mistake please contact us.'); 
    } 
    $team_terms = db_query('select terms from gm_team where id = :team_id',array(':team_id' => $team_id))->fetchfield(); 
    $team_requirements = db_query('select recruit_requirements from gm_team where id = :team_id',array(':team_id' => $team_id))->fetchfield(); 

...... 
} 
+0

您可以使用1)Db來存儲數據,以便表單都可以訪問它。 2)至於重定向,你可以做到這一點與jquery –

+2

[這](http://growingventuresolutions.com/blog/drupal-7-multistep-forms-using-variable-functions)可能會幫助你 – hampusohlsson

+0

hakanito的鏈接是正確的處理這種情況的方法,除非你真的有理由不把它做成多種形式。 – Coder1

回答

1

Hanito的鏈接到你的問題的評論中的多形式的例子將是我的第一個建議......但是,如果你真的需要形式B是一個單獨的形式或超出你的控制,你可能只是存儲窗體的值A在會話var中,然後將$ form ['redirect']值設置爲表單b的路徑。

示例。

function recruitment_select_team_submit($form, &$form_state) 
{ 
    // Forward to the next page. 
    $items['yourmod/foo/%/delete'] = array(
    'title' => 'goto next page', 
    'page callback' => 'drupal_get_form', 
    'page arguments' => array('recruitment_form', 1), // second argument is the paramter for the team_id (test value) 
    //'access arguments' => array('delete foo rows'), 
    'access callback' => TRUE, 
    'type' => MENU_CALLBACK, 
    ); 

    $_SESSION['form_a_values'] = $form_state['values']; 
    $form['redirect'] = 'path/to/form/B'; 
}