Welcome Guest, Not a member yet? Register   Sign In
is there a way to reset Validation class?
#1

[eluser]Chillahan[/eluser]
I have a multi-page registration form process. To go page to page I am doing:

Code:
if ($this->validation->run() == FALSE)
        {
            // load the view for the current page again, which will also show validation errors;
        }
        else
        {
            // load view for the next step;
        }

However, when I load the view for the next step, it will show a validation error, even though the user has not had a chance to enter data yet. If, instead, in the else case, I use the redirect() function, then of course it works. I assume the validation class is using some sort of cookie to store whether the page it is validating has already been viewed once or not (based on URL), and so when I use load to get the next page up it fails and shows an error right away (since URL looks the same).

Now, I realize that using redirect is pretty simple, but I still think using load is cleaner since it avoids doing a redirect. Originally I thought it would be more secure too, since I could make the other registration steps more private by prefixing hem with _, but then quickly realized that doesn't work since then a user can't view the second steps or beyond if they don't enter data correctly (since those steps' forms do submit to their own controllers).

Perhaps I am just being silly and the only way to do it is to redirect to the next form page upon successful completion of the current page? I am having to check cookie/session data anyway to ensure people can't skip to the middle of the registration process, so really this is becoming more of a theoretical question.
#2

[eluser]charlie spider[/eluser]
ummmmm... i'm not sure if i have the correct name for the variable but you could set

$this->validation->error_string = '';

as some point between the two pages
#3

[eluser]Chillahan[/eluser]
Oh right - I keep thinking this is like C++ where such a property would be read-only. Smile

Anyway I guess by using redirect() I can keep the user form refreshing form data - not that I don't check for duplication upon database insertion, but actually I am not sure what would happen if they refreshed in the middle of a four page registration process... technically they'd be reloading the controller that started off the multi-page process, not the one that control was most recently passed to, so it would seem they'd end up bring themselves all the way back to the beginning. So then I'd need to add code to check what stage they were at in that initial default controller - ahhh, I think I'll just keep it using redirect().

Thanks for responding to one of my posts again!
#4

[eluser]charlie spider[/eluser]
wait a minute,

if they fail validation on page two then they shouldn't be allowed to progress to page three.
so by getting to page three, there should be no errors and therefore no error messages!!!
assuming that page three doesn't have any inputs with the same field names

am i missing something ???

it is 20 minutes to 1 am on a Friday night and i am working on code ( and have been working since 8 am ) so my brain is kinda fried right now, so i could be missing something...
#5

[eluser]ontguy[/eluser]
Maybe you could use CI sessions tracked which pages have been validated, then redirect to the page that completing.




Theme © iAndrew 2016 - Forum software by © MyBB