We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Forward with validation errors

Hi, I have 2 actions in controller.

signupAction and signupPostAction

in first is form view (based on phalcon Form class).

I action post I create signup form object and call to action isValid. If result this method is false. I'd like forward to signupAction, but with display errors.

In view I have form.message('name') and when validation is in action signupAction, messages are display.

How can I set same messages in forward or redicrec action?

Below is code of my messages method:


public function messages($name){
        if($this->hasMessagesFor($name)){
            foreach($this->getMessagesFor($name) as $message){
                $this->flash->error($message);
            }
        }
    }

After modified class (form is as class property), I see errors. But still I think if is possible add only errors to forward.

Regards, Jarek



2.1k

Did you mean: https://docs.phalcon.io/en/latest/reference/flash.html#implicit-flush-vs-session

use flash session so that you can display error after redirection.