Welcome Guest, Not a member yet? Register   Sign In
an array as input in form_input
#1

[eluser]jtan[/eluser]
I plan to have several text field in the form, is it possible to have an array on the form_input?
#2

[eluser]ELRafael[/eluser]
Short answer : YES :lol:

View file
Code:
<?php foreach ( $itens->result() as $i ) : ?>
  <input type="checkbox" name="ids[]" value="<?php echo $i->id; ?>" />
<?php endforeach; ?>

Controller file
Code:
$id = $this->input->post('ids', TRUE);
foreach ( $ids as $id )
{
  //Do something with $id
}
#3

[eluser]jtan[/eluser]
can I make spreadsheet like thing with several form_input and use array to have several variables?
#4

[eluser]ELRafael[/eluser]
Sorry but I didn't get.

Try to put some examples, maybe I can help you.
#5

[eluser]jtan[/eluser]
like i wanted to make a spreadsheet out of using several form input fields then each fields represent an element in the array

variable[x][y]

where X is column and Y is row

i won't have memory hog problem having 64 x 120 array?
#6

[eluser]ELRafael[/eluser]
Yes, you can.

Code:
<input type="checkbox" name="ids[][]" value="<?php echo $i->id; ?>" />

Look the name="ids[][]"

If you do a
Code:
var_dump($this->input->post('ids'));
you'll see your array.

The memory can be a problem. Depends how you write your code, in special the loop section.




Theme © iAndrew 2016 - Forum software by © MyBB