dream198731 2011-03-25 03:59
浏览 37
已采纳

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!

  • 写回答

1条回答 默认 最新

  • douchen9569 2011-03-25 04:18
    关注

    you should get your post variable like

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

    (there is no $ sign)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?