php - In CodeIgniter 2.2.0, why does the form validator not invoke my custom validation routine on array input data? -


here's situation: while building project in codeigniter 2.2.0, attempting validate tabular form custom data validator. tabular form set transmit post data server in standard array format, , using non-zero based numeric keys. keys, encode important data, happened start 1 on form attempting debug. noticed codeigniter's form_validation class invoking validator on 2nd , 3rd row of data (with keys 2 , 3, respectively) not first row (with key 1).

why should so? codeigniter form_validation documentation indicates can use non-numeric array keys, 1 expect non-zero numeric array keys work too.

after debugging, found form_validation::_execute() (in system/libraries/form_validation.php) has $cycles variable, zero-based integer, measures number of times particular rule has been invoked on array-based input. unfortunately, __execute() function uses $cycles variable reference elements of post data (e.g., line 552 in build, appears 2.2.0). has result of bypassing input array elements not keyed zero-based integers. solved problem changing array keying scheme zero-based count, , encoding elsewhere data had been putting in keys.

perhaps fixed in codeigniter 3, out there still using codeigniter 2 , validating array input forms using default validation tools, watch out this.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -