this is why i need to relaunch my controller action with a defined step as parameter if an error occurs.
example:
public function actionmy_action($step) {
switch ($step):
case 1:
//(the first step of my form)
case 2:
//(the 2nd step of my form)
if ($model->hasErrors()) #if an error is found here
{
// back to step 1
$this->actionmy_action(1);
}
endswitch;
I think there is a bug from the PHP interpreter because it gets a syntax error with :
public function actionmy_action($_GET['step']=1) {}
result:
Parse error: parse error, expecting `')'' in C:\wamp\www etc....
I asked for this because I wanted to avoid using of redirect(), because this sends new redirection headers so the browser will have to reask for a new ‘controller/action/step’ (HTTP GET /controller/action/step )
public function actionMy_Action()
{
$step = (isset($_GET['step']) ? $_GET['step'] : 1);
switch ($step)
{
....
}
}
This syntax:
public function actionmy_action($_GET['step']=1) {}
is wrong. Firstly, with Yii action functions do not have parameters passed to them. Secondly, you should not (and cannot) assign default values to super global variables like this.