I have a two-stage form-filling process that I am trying to implement. Users enter data into a form, submit and are then taken to another page where they see the form data they just submitted and are presented with further fields to fill in.
Here is the relevant controller psuedo-code:
public class MyController extends Phalcon\Mvc\Controller{
public function newAction($id){
...
if($this->request->isPost()){
if($form->isValid($this->request->getPost()) != false){
$insert = new MyModel();
$insert->assign(array( ...));
}
if(!insert->create()){
//display errors
}else{
//insertion has succeeded
$this->dispatcher->forward(array("controller"=>"MyController","acton"=>"edit","params"=>array($study->getPkStudy(),$saereport->getId())));
}
}
The forward directive causes the page to submit like 10 times, which results in many insertions of $insert and eventually phalcon returns with a compaint about ifinitue loop. How can I redirect to another page after a post?