CodeIgniter Forums
$this->form_validation->set_rules("array[$key]", '', ""); - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: $this->form_validation->set_rules("array[$key]", '', ""); (/thread-33800.html)



$this->form_validation->set_rules("array[$key]", '', ""); - El Forum - 09-08-2010

[eluser]megabyte[/eluser]
So I have two forms, one adds and one edits. Data is stored in the database.

The form has an array of text fields.

On the edit form you'll have the fields named as such

Code:
field[]
field[]
field[]

and I use

$this->form_validation->set_rules("field[]", '', "callback_function_here");

but when you edit, those fields have keys so that they match a field in the database table.

So as far as I can tell, I can't do this anymore when I edit, because I am populating the form as such

Code:
field[primary key]
field[primary key]
field[primary key]

$this->form_validation->set_rules("field[]", '', "callback_function_here");

Any suggestions on a simple solution that works every time? Keeping in mind I need to keep using an array of text fields.

thanks.


$this->form_validation->set_rules("array[$key]", '', ""); - El Forum - 09-09-2010

[eluser]megabyte[/eluser]
no one has an answer?