Cos
Cos

Reputation: 1709

CakePHP: Keep validation data upon redirect

I have seen this problem mentioned a lot here, but I couldn't find any satisfactory answer, so I'll try to formulate it a bit differently:

I have a login form and a registration form for users on the same page (let's call it the "frontpage").

Each form leads to a different controller action. Upon validation, cakephp is trying to display the validation errors in the users/login and users/register Views, but I don't have and I don't want those Views, so I'm forced to do a redirect back to my "frontpage". However, upon redirecting, the validation data is lost.

How do I go about keeping the validation data to be displayed on my frontpage, without having to add separate pages for the login and register functions?

Upvotes: 0

Views: 1919

Answers (1)

Kishor Kundan
Kishor Kundan

Reputation: 3165

Cakephp keeps its validation errors in

$this->ModelName->invalidFields();

If you want it to behave persisten the i believe you will have to keep it in a session variable. i.e if your redirects are loosing the property value then try keeping it in a session variable.

Update:

invalidFields executes the whole validation process again and $this->ModelName->validationErrors should be used instead.

Upvotes: 1

Related Questions