Validation with array field names ? |
[eluser]Juan Velandia[/eluser]
If I have this Code: <?php echo form_open('form'); ?> Code: $this->form_validation->set_rules('number', 'Number', 'required'); Any ideas? Thanks in advance!
[eluser]Aken[/eluser]
Use a callback or extend the form validation library with your own rule(s). The default rules are not set up to handle arrays.
[eluser]Juan Velandia[/eluser]
Plop, I think I will go with JS and getElementById, thanks
[eluser]Aken[/eluser]
You shouldn't rely on JS by itself to validate data, since anyone can circumvent it by simply turning JS off.
[eluser]LuckyFella73[/eluser]
I never tried but according to the user guide you can set rules for arrays: Code: // example from User guide: http://ellislab.com/codeigniter/user-gui...ationrules Section "Using Arrays as Field Names" EDIT: In your case that should work: Code: $this->form_validation->set_rules('number[]', 'Number', 'required'); |
Welcome Guest, Not a member yet? Register Sign In |