[1.7.2] form_validation matches[] multidimensional array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [1.7.2] form_validation matches[] multidimensional array (/showthread.php?tid=27750) |
[1.7.2] form_validation matches[] multidimensional array - El Forum - 02-19-2010 [eluser]Unknown[/eluser] This is the return from the $this->CI->form_validation->_config_rules var. The issue is here... matches[user_change_password[password]] Code: Array I have been using the matches validation for a while, however this is the first instance I use a multidem array. I get the following UI error... Quote:The Confirm New Password field does not match the user_change_password[password field. Looks like it cuts the multidem bracket (missing "]") to gather the field name in the "matches[]" validation. I suspect this is a bug since multidem array names work with everything else in the form_validation class. I expect the validation class to return user_change_password[password] and NOT user_change_password[password from matches[user_change_password[password]] [1.7.2] form_validation matches[] multidimensional array - El Forum - 01-26-2011 [eluser]Unknown[/eluser] Reemplaza la funciĆ³n matches de la clase CI_Form_validation de la siguiente forma: function matches($str, $field) { $x = explode("[", $field); if ( ! isset($_POST[$x[0]])) { return FALSE; } $field = $_POST[$x[0]]; if(isset($x[1])) $field = $field[$x[1]]; return ($str !== $field) ? FALSE : TRUE; } The problem is in the POST where you use a array, my fast solution is this, but not is not good. If you know any solution, do not forget to comment. Sorry, my english is not very good... jeje [1.7.2] form_validation matches[] multidimensional array - El Forum - 01-29-2011 [eluser]bilawal360[/eluser] I've come under this as a problem. The only fix for this right now is to make another $_POST input without the [] and insert that into the form validation rules. An example in your case would be the following: Code: $_POST['user_post_password_tmp'] = @$_POST['user_change_password']['password']; And then in your validation rules: Code: required|matches[user_post_password_tmp] [1.7.2] form_validation matches[] multidimensional array - El Forum - 02-15-2011 [eluser]Canimus[/eluser] I have found the same problem when having this form Code: <?php echo form_label(lang('label_password'), 'user[password]'); ?> This is the modification in the system/libraries/Form_validation.php Code: function matches($str, $field) That help me to overcome the arrays in posts. This solution will not work with multidimensional arrays!. Hope this works for you! Canimus#12 [1.7.2] form_validation matches[] multidimensional array - El Forum - 08-01-2011 [eluser]ssyberg[/eluser] The subject of this post is "is this a bug?". The answer is yes and it should be submitted as such. |