CodeIgniter:将数组从表单传递给控制器​​,然后传递模型以插入数据库

CodeIgniter:将数组从表单传递给控制器​​,然后传递模型以插入数据库

问题描述:

I've got a form in a view. The following row can be duplicated over and over allowing the client to add as many trashcans as they wish: https://gist.github.com/886337

The problem starts when I try to get the array from $invoice_item

If I have just one line item:

I've tried $invoice_items = $this->input->post('$invoice_item');

but if I do var_dump($invoice_items); to see what I have I get bool(false)

So, I tried: $invoice_items = array($this->input->post('$invoice_item'));

and again var_dump gives me this: array(1) { [0]=> bool(false) }

And then I've tried other things like adding [] after $invoice_items or $invoice_item but nothing seems to work. I just don't know what I'm doing?

Any help would be appreciated because I am lost!

you should get your post variable like

$invoice_items = $this->input->post('invoice_item');

(there is no $ sign)