Welcome Guest, Not a member yet? Register   Sign In
form_validation - run($ruleset) doesn't take precedence?
#1

Disclaimer : I am sorry if my use of terms isn't correct. I hope what I mean can be discerned through context. I'm still pretty fresh-faced when it comes to PHP/CI/etc.

I'm running the form validation on a form in which it is necessary to perform cascading validations, like

Initial validation
   If (CASE)
       Secondary Validation
   If (Another CASE)
       Tertiary Validation
and etc.

I discovered something... odd and I'm not sure if it's oversight or intended behavior.

I'm taking advantage of the Form_validation configuration functionality (because it's awesome) and I have several "rule" sets within that file.

When testing validation on my form, I have discovered that the initial validation worked, but the secondary (and likely by extension tertiary) validations were basically being skipped.

On digging a little deeper, I discovered this line of code within the Form_validation library :

Code:
if (count($this->_field_data) === 0){

When I read the rest of the run(...) function, it became clear to me that the _field_data variable is set when run is called with a proper rule set... but that's it. If run is called again in the same post, then the old rule set is still in force, even if it's called with a new rule set.

So I'm thinking it might be better to force run() to assign a new rule set each time it's called (which may result in some more overhead) if run is called with a ruleset (instead of being called empty).

So... Is there a reason that this is not the case? (Again, I'm pretty new to this, so it could be something pretty "Duh" to everyone else).
Reply


Messages In This Thread
form_validation - run($ruleset) doesn't take precedence? - by Geoclasm - 10-28-2015, 12:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB