In my cakephp form I have following code
<p> <?php echo $form->input('option[]',array('size'=>13)); ?> </p>
<p> <?php echo $form->input('option[]',array('size'=>13)); ?> </p>
<p> <?php echo $form->input('option[]',array('size'=>13)); ?> </p>
<p> <?php echo $form->input('option[]',array('size'=>13)); ?> </p>
I am trying to get values from a set of input text boxes, the number of text boxes can be set by the user, so cant give individual names of each text box, but How can I get values from my controller to insert data to db table
Thank you
You can leave the form as it is (and use suggestions from @Wizzard and @Lee), but the best practice is to use an incrementing variable to construct the list. i.e.:
This way your variable after posting the form will look like:
data[MyModel][0][option] = ‘the value’
dataMyModel[option] = ‘the value’
data[MyModel][2][option] = ‘the value’
… and so on…
In the controller you can access the posted data by:
print_r($this->data);
Take a look saveAll() (search for saveAll in your browser and look for suggested data structure)