![]() |
CI 2.1.0 form validation external callbacks via the newly available param - 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: CI 2.1.0 form validation external callbacks via the newly available param (/showthread.php?tid=47178) |
CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 11-28-2011 [eluser]skunkbad[/eluser] I've done my share of bitching about CI lately, nevertheless, I thought I'd share a little code that makes working with bigger applications more manageable. CI does not by itself accommodate external callbacks for form validation, and models are a great place to store them, since the CI super object is accessible from inside them. What I've done is created a generic external_callbacks method in MY_Controller. The method explodes the comma seperated string that contains the model name, method, and any arguments that should be passed along as an array. Here is the method: Code: /* CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 01-26-2012 [eluser]ajustesen[/eluser] CroNIX... do you mind giving a quick example of how you used it with a controller and a model, can't seem to get your Form_validation library version to work. CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 02-02-2012 [eluser]erikig[/eluser] Hey Brian, Just wanted to say thanks, its a mighty elegant fix. This was one of the more annoyances of Form Validation (the other being that it only works on _POST instead on any input i.e _GET, _COOKIE etc) E CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 02-02-2012 [eluser]CroNiX[/eluser] @ajustesen I'm sorry I didn't see your post til now. Please start a new thread and post what you have tried and I will help. I don't want to mess with Brians thread and I apologize to Brian for posting in his. CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 02-03-2012 [eluser]skunkbad[/eluser] [quote author="erikig" date="1328234983"]Hey Brian, Just wanted to say thanks, its a mighty elegant fix. This was one of the more annoyances of Form Validation (the other being that it only works on _POST instead on any input i.e _GET, _COOKIE etc) E[/quote] I've never heard of submitting a form with cookie data, but of course $_GET functionality would be useful. Glad you found the code useful. CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 04-19-2012 [eluser]theshiftexchange[/eluser] just wanted to say thanks - this code is so awesome CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 04-19-2012 [eluser]chenx[/eluser] Hello. Thanks for skunkbad for solving my problem with Form Validation. But still, I have some things needed to be solve here, it's the error message. Because we're using the function external_callback, the error message only return the error for external_callback. How can I return the error message from each of my model function? Sorry for my bad english. Thanks for helping. CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 04-19-2012 [eluser]theshiftexchange[/eluser] [quote author="chenx" date="1334897650"] Because we're using the function external_callback, the error message only return the error for external_callback. How can I return the error message from each of my model function? [/quote] You always use the 'external_callback' error message - it will display the error for each of your models as needed CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 05-09-2012 [eluser]LeMec[/eluser] Hello, Thanks, for this skunkbad. I looked at your community auth and tried to take the My_form_validation and use it in my project. I am using HMVC so it did not work. I also have my models organized in sub directories so the code could not find the specified model. I have made a few changes that seemed to fix the problem for me... Code: public function external_callbacks( $postdata, $param ) Edit: I also need to enter the full path of where my model is in my validation rules... So, if I did not enter a path, then this would not find the model, but If I entered a path, then it would find the model load it but when trying to use it it would reference the object with the path. CI 2.1.0 form validation external callbacks via the newly available param - El Forum - 09-29-2012 [eluser]skunkbad[/eluser] I've revised the way I'm using external callbacks. I just wanted to be able to use libraries and models at the same time. See comments: Code: /** |