Neyoex
Neyoex

Reputation: 81

Keeping certain variables after model validation rules fail in cakephp 2.0

So I'm using jquery tabs for a page with a form, and we're using certain php variables like $image (with data such as dimensions and path) in if isset conditions inside the view to "unlock" further tabs as the user completes actions (such as uploading an image at this example). At some point I have to use some validation rules, and the problem is if the user makes an error and validation rules fail, the page is reloaded with the variables $image etc gone, so the user basically has to start the form from the beginning (locked tabs and all).

At the moment I'm using something like this:

if ($this->Report->save($this->data)) { //validation rules run here
    //do stuff
else{
    $this->set("err", 1);

so I can at least have some of the tabs unlocked on page reload using the $err variable, but I also need to maintain specific variables with actual data like $image that I mentioned before (to show a preview), which I cannot figure out a way to do.

Any thoughts?

Upvotes: 0

Views: 118

Answers (1)

Bimp
Bimp

Reputation: 494

You could store your data in the session and delete them when appropriate

Upvotes: 1

Related Questions