Validation: Multiple Callbacks on Non-Required Field - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Validation: Multiple Callbacks on Non-Required Field (/showthread.php?tid=58791) |
Validation: Multiple Callbacks on Non-Required Field - El Forum - 07-20-2013 [eluser]Simple Gifts[/eluser] I have a form field that may be blank, but if it isn't blank, it requires several callbacks to review it. Here's where I set the rule: $this->form_validation->set_rules('txtSplitCC', 'Split Payments/CC', 'trim|'. 'callback_stripCommas|'. 'callback_verifySplits['.$curTotal.',false]'); Function stripCommas always returns a string, so it never returns false. The second callback is never called. It appears that if a field is not required, only the first callback is called in the form validation code. Looking into codeIgniter's system function (version 2.1.3) _execute($row, $rules, $postdata = NULL, $cycles = 0), file Form_Validation.php, it appears that all callbacks are skipped after the first callback inside the rules processing loop: Code: // If the field isn't required and we just processed a callback we'll move on... This is a problem, since I need to work through several callbacks to fully review the input. Any suggestions? Thanks. Validation: Multiple Callbacks on Non-Required Field - El Forum - 07-22-2013 [eluser]noideawhattotypehere[/eluser] I had a problem using callbacks, but i found solution over the web: make your own library named MY_Form_validation and paste this code Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); usage: Code: $this->form_validation->run($this) |