Welcome Guest, Not a member yet? Register   Sign In
Validation Bug Errors all the time
#1

[eluser]Open Book software[/eluser]
in the last version of CI (1.6.1) we got a bug at the Valdation Class or CI_Validation in the method run() at line 237.

Problem:
This line sets the validations errors all the time, so if you get to a particular (first time) page where a validation is set (get to this page due to a post event), all the validation errors are reported, and thats not normal, validation at older version (1.5.4) this line did not exist and errors where reported only when user submit data from that particular page and not when he gets there by first time.

Suggest:
Have we missing something that made this line appear???
#2

[eluser]coolfactor[/eluser]
So on your site, you're navigating to a page using POST, but not as a result of a form submission?

I agree that should be addressed, but you can easily work around that problem by wrapping your call to Validation::run() in a $_POST check. Only have run() called if your controller function detects the submission of an applicable form.

Code:
if (isset($_POST['submitted']) && $this->validation->run()) {

}

That way, run() isn't even called unless the "submitted" variable exists. You could check for any expected field.

Proper logic anyway.
#3

[eluser]Open Book software[/eluser]
So your answer does not please me, because if you assume that I have to take care every time for something that came by $post thats not the concept from CI 1.5.4 and later, because every component came by post but not from a 'submit post' we should not worry about it, just remove the line I posted and notice that you should not worry about that 'manual check' work, Can you or some else explain me the reason of always show the errors on this line in the validation class??

thanks for listening
#4

[eluser]coolfactor[/eluser]
The current design of the Validation class works by checking the $_POST array. Your code is calling the run() method every time, and therefore the errors are appearing. My suggestion was to avoid calling run() when it's not needed.

Can you post some of your code that implements the Validation class? That may help me offer help that pleases you.




Theme © iAndrew 2016 - Forum software by © MyBB