![]() |
Validation callback that changes value doesn't work on arrays? - 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 callback that changes value doesn't work on arrays? (/showthread.php?tid=54447) |
Validation callback that changes value doesn't work on arrays? - El Forum - 09-09-2012 [eluser]CodeIgniterNewbie[/eluser] I have a callback as part of my form validation. Assume this callback changes the value that was passed. If I apply the callback on a non-array field, it works fine. But if I apply the callback on an array field, it doesn't work. Any ideas what might be wrong? Code: $this->form_validation->set_rules("foo", 'Foo Field Name', 'callback_change_foo'); // will work Validation callback that changes value doesn't work on arrays? - El Forum - 09-09-2012 [eluser]siptik[/eluser] if you use a string as the key of the array, it does not work. Validation callback that changes value doesn't work on arrays? - El Forum - 09-09-2012 [eluser]siptik[/eluser] And with a numeric key does not work This works if the array key is numeric and starts with 0 and in numerical order Validation callback that changes value doesn't work on arrays? - El Forum - 09-09-2012 [eluser]CodeIgniterNewbie[/eluser] Ah, OK. My array is actually associative. For example, foo[bar][blah][blah]. I still need to validate this. How do I do this? Validation callback that changes value doesn't work on arrays? - El Forum - 09-10-2012 [eluser]siptik[/eluser] You must do validation for each field. For example: Code: $this->form_validation->set_rules("v[a]", 'Foo Field Name', 'callback_change_foo'); result: Array ( [v] => Array ( [b] => some new value for sdf [a] => some new value for aaa [c] => some new value for ssss ) [add] => Отправить ) Validation callback that changes value doesn't work on arrays? - El Forum - 09-10-2012 [eluser]siptik[/eluser] although I think that should do it automatically. Sorry, my English is bad :red: Validation callback that changes value doesn't work on arrays? - El Forum - 09-10-2012 [eluser]CodeIgniterNewbie[/eluser] siptik, have you tried your code? My code is basically the same thing. It's not working for me. If it's working for you, then I am doing something wrong. [quote author="siptik" date="1347263545"]You must do validation for each field. For example: Code: $this->form_validation->set_rules("v[a]", 'Foo Field Name', 'callback_change_foo'); result: Array ( [v] => Array ( [b] => some new value for sdf [a] => some new value for aaa [c] => some new value for ssss ) [add] => Отправить )[/quote] Validation callback that changes value doesn't work on arrays? - El Forum - 09-10-2012 [eluser]Beginers[/eluser] ILL SHARE MY KNOWLEDGE TO YOU ALL. I ALSO USE ARRAY IN MY WEBSITE HERE IT IS CONSIDERING I HAVE A MULTIPLE ARRAYS OF NAME: VIEW Code: <?php echo form_open('controllername/functioname');?> CONTROLLER Code: $countinput = count($this->input->post()); I hope this help. im just a beginers hehe. if you have any questions fill free to PM me Validation callback that changes value doesn't work on arrays? - El Forum - 09-10-2012 [eluser]CodeIgniterNewbie[/eluser] But you have an indexed array, not an associative array. Validation callback that changes value doesn't work on arrays? - El Forum - 09-10-2012 [eluser]Beginers[/eluser] (EDITED) it now on you on how will you manage the code...for an instance Code: $characters="abcdefghijklmnopqrstuvwxyz"; OUTPUT Code: name[a] |