Validation Callbacks!!! - 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: Validation Callbacks!!! (/showthread.php?tid=9855) |
Validation Callbacks!!! - El Forum - 07-10-2008 [eluser]reset[/eluser] Hello all!! I have a form with two multiple list. I move options from one multiple to the other one in order that the user want. I must validate that first multiple is empty and the other one have all the options... How I can do that? I do this, but doesn't work, sorry for my english: Code: $rules['grupos1'] = 'empty'; Thanks Validation Callbacks!!! - El Forum - 07-10-2008 [eluser]Bramme[/eluser] I don't really understand what you need. Could you show us the page (or maybe even just a screenshot) and try to explain a bit better what you need. Validation Callbacks!!! - El Forum - 07-10-2008 [eluser]reset[/eluser] Hello Bramme, I attach one file with two screenshot. - The first is the initial state for the user. - In the second, the user selects all options in the first "multiple select" and put into the second in the order that he wants. I must validate that first multiple select is empty, and I have tried the options that I related in the first post. Thanks Validation Callbacks!!! - El Forum - 07-10-2008 [eluser]reset[/eluser] I do that in MY_Validation, and works, but I don't know if it is necessary. Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); And I do this for validation: Code: $rules['grupos1'] = 'is_empty'; Validation Callbacks!!! - El Forum - 07-11-2008 [eluser]reset[/eluser] have somebody any idea? Validation Callbacks!!! - El Forum - 07-11-2008 [eluser]Bramme[/eluser] I don't see a reason why you would extend the CI_Validation library. And you started off good, you have to make your own custom callbacks... Code: $rules['grupos1'] = 'callback_empty'; You don't have to echo true though. Add this to your controller: Code: function empty($str) { Validation Callbacks!!! - El Forum - 07-13-2008 [eluser]reset[/eluser] Hi Bramme, I add empty to MY_Validation, and it doesn't work. My Code is: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); And that is the error: Parse error: parse error, unexpected T_EMPTY, expecting T_STRING in C:\Program Files\EasyPHP 2.0b1\www\uahlabs\system\application\libraries\MY_Validation.php on line 31 Thanks Validation Callbacks!!! - El Forum - 07-13-2008 [eluser]Bramme[/eluser] try changing it to Code: if(empty($param)) { Validation Callbacks!!! - El Forum - 07-13-2008 [eluser]reset[/eluser] Hi Bramme, It doesn't work because 'empty' is one of words of the "List of Reserved Words" of php. I thought that could calling php functions from "validation rules" but I see that this is not possible. Thanks |