Hi, I'm studying the response->redirect
; and I encounter 2 strange results:
- validation - after redirection, seem like it's going to validate one more time. For example I insert a row that contains unique value, after the redirection it throws me an error. This problem will not occur for
forward
. - flash session message - similar to validation, a flash message will output twice, and doesn't happen when using
forward
.
Have any of you encounter this problem?
update:
The strange thing is the same code (haven't change anything, no return) magically produce different result:
- validation didn't work yesterday works today.
- flash session message still output twice even with return.
they're the simplest code.
public function testAction(){
$systemUser = new SystemUsers();
$systemUser->username = 'un1'; // this column is unique
if(!$systemUser->save()){
foreach($systemUser->getMessages() as $message){
$this->flash->error((string) $message);
}
$this->view->disable();
$this->response->redirect('test/fail');
return;
}else{
return $this->forward('test/success');
}
}
note: apparently the same action (testAction) is executed twice (it happens that it executed four times).
related stackoverflow