CI Form_validation problem |
[eluser]i_am_using_ci[/eluser]
Code: <?php The problem is: When I submit my form I am getting integer from to_delete[] array after $this->form_validation->run(), I've tried to post it as bug, but got an advice to ask here, maybe I made mistake somewhere...
[eluser]TheFuzzy0ne[/eluser]
The validation callback should return TRUE if validation was successful, and FALSE is it wasn't. Also, you'll need to grab the array by reference. Code: function _ids_handler(&$ids = array()) { // grab the argument by reference. With a bit of luck, that should work for you.
[eluser]pistolPete[/eluser]
[quote author="TheFuzzy0ne" date="1234834097"]The validation callback should return TRUE if validation was successful, and FALSE is it wasn't.[/quote] Well, not really. The user guide says: Quote:If your callback returns anything other than a boolean TRUE/FALSE it is assumed that the data is your newly processed form data.
[eluser]TheFuzzy0ne[/eluser]
I missed that. Now I remember, because trim passes back the data. Also, I've realised that it is a string that being passed to the validation function and not an array as I'd thought.
[eluser]i_am_using_ci[/eluser]
Same typo error for class constructor, sorry, let me try to use reference (but without template_id with only to_delete[] argument validation was successfull and correct)
[eluser]TheFuzzy0ne[/eluser]
That validation library appears to iterate through the object, and pass each one to the function (so the validation function is called once for each row in your array).
[eluser]TheFuzzy0ne[/eluser]
I think this thread may help you. http://ellislab.com/forums/viewthread/51260/
[eluser]i_am_using_ci[/eluser]
Ah, okay, now understand that logic. Got my code working. But still same question, how can it be when I have validation method for associative array and it's the only thing that I send throught post form - it's get validated successfully, and when I set more than 1 rule in addition to that array rule, I need validation method for every array element? |
Welcome Guest, Not a member yet? Register Sign In |