dynamic inputs and validation |
[eluser]robert.fulcher[/eluser]
I am trying to validate and repopulate fileds on a form that I also add dynamically. Not dynamically from JavaScript but from database variables. I have a preferred number of fields that will be added to a form. Form HTML Code: <?php echo form_input('value['.$howmany.']', set_value('value['.$howmany.']')); ?> <?php echo form_error('value['.$howmany.']'); ?> Generated HTML Code: <input type="text" name="value[1]" value="" /> Controller Code: $this->form_validation->set_rules('value[]','Communication Value'); I read about some posts that addressed the index value in the array with patches and things. I am still new to CI so I am not sure if this is supposed to be working or not. The re-population does not work. Any help would be great. Thanks
[eluser]robert.fulcher[/eluser]
Still looking for input on this if anyone has it. Am I even close with how this should work? Thanks
[eluser]LuckyFella73[/eluser]
Hi Robert, did you try to set up the input fields this way ? Code: <input type="text" name="value[]" value="" /> I didn'd test but looking at the user guide it seems to be the direction to go. Have a look here: http://ellislab.com/codeigniter/user-gui...ysasfields
[eluser]xwero[/eluser]
Normally it should work to validate an array but as the dynamic fields come out of a database why not do Code: <?php echo form_input('value_'.$howmany, set_value('value_'.$howmany)); ?> <?php echo form_error('value_'.$howmany); ?> Code: for($i=1;$1<=$data['howmany'];$i++) |
Welcome Guest, Not a member yet? Register Sign In |