0

得到一个等待参数的动作,要运行这个动作,我总是需要一个参数。但同样在这个动作中,我对其他表单进行验证,之后我的第一个变量总是消失。$var在 isValid 之后我如何保持这个?

public function myAction(){  
   if ($this->getRequest()->isPost() || $this->getRequest()->getParam('number')){  
     //this is where got my number
     $number = $this->getRequest()->getParam ('number');
     //and use to display site.        
    if ($this->getRequest()->isPost()){
      if($commentForm->isValid($this->getRequest()->getPost())){
         //if I get Valid data I do upload or etc.
      } else {
             //but if form is inValid won't display everything one more time.
             //but **$number is now Null**.  
             $this->view->data = $tUser->getCommentAndUserByTelephone($number);
             $this->view->commentForm = $commentForm;
        }
      }
    }
  }

我怎样才能在$number不重新发布的情况下保留它?

4

2 回答 2

0

传递该号码以查看$this->view->number = $number;并重新发送它,而不是一个新号码。简单的!

于 2013-10-30T09:46:51.847 回答
0

您可以尝试将其与会话一起存储。

http://www.w3schools.com/php/php_sessions.asp

$_SESSION['numbers'];
于 2013-10-18T14:14:54.023 回答