我正在symfony 1.4上工作,我有一个indexSucces文件,在那里我显示了一个表单,这个表单有文本框,你输入数据,并有两个选项的组合。如果用户选择选项1并单击按钮,则将数据发送到动作1,如果用户选择选项2,则将数据发送到动作2。但是除了用户提供的数据外,还必须发送其他数据。这是indexSuccess
的代码 <form method="post">
<?php echo $form['textfield']->render(); ?>
<?php echo $form['combo_options']->render();?>
<input type="submit" value="enviar" name="enviar"/>
</form>
actions.class.php
的代码public function executeIndex(sfWebRequest $request){
$this->form=new FormularioForm();
if($request->isMethod('post')){
if($request->getPostParameter('enviar')){
$data=$request->getParameter('textfield');
$option=$request->getParameter('combo_options');
if($option=='1'){
$data_extra=array(1,2,3,4,5);
//How with the post method to send the $data and $data_extra to the next action1?
$this->redirect(aplication/action1);
}else{
$data_extra=array(8,9,7,5);
//the same here
$this->redirect(aplication/action2);
}}}
public function executeAction1(sfWebRequest $request){
//Here I receive the data sent with $ request-> getParameter ()
}
我建议您将额外的数据存储在用户会话中,例如:
// Store data in the user session
$this->getUser()->setAttribute('extra_data', $extra_data);
$this->redirect(...);
}}}
public function executeAction1(sfWebRequest $request){
// Retrieve data from the user session with a default value
$extra_data = $this->getUser()->getAttribute('extra_data', array('no elem'));
}
更多信息在这里
希望对您有所帮助