我有表格A和表格B.
我想让表格A将用户重定向到表格B并告知表格B表格A中的选择
表单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)
Hanito在你的问题的评论中链接到多形式的例子将是我的第一个建议...但是如果你真的需要表格B作为一个单独的表格或超出你的控制,你可能只是存储表格的表格值在会话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';
}