CodeIgniter Forums
passing array to custome form validation function - 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: passing array to custome form validation function (/showthread.php?tid=35407)



passing array to custome form validation function - El Forum - 10-28-2010

[eluser]Unknown[/eluser]
Hi all
lets say that $x contains array of ids
i want to validate this array using callback_duplicate,i do the following:
$this->form_validation->set_rules('x[]',..., 'trim|required|callback_duplicate['.$x.']');

and the function is:
function duplicate($x)
{...........}

but the previous statement only pass the first element to the function, not all array
how to pass array to custom form validation function
thank you


passing array to custome form validation function - El Forum - 10-28-2010

[eluser]Fireclave[/eluser]
$this->form_validation->set_rules(‘x’,..., ‘trim|required|callback_duplicate’);

write the x without the [], then should it works.