简体   繁体   中英

Get input Array Laravel not working

I'm creating an array of input in my form. And i wanna get this array on my controller in Laravel.

My inputs is hidden type, and i add this fields dynamically through JavaScript, using Backbone.

I add this inputs on my form:

<input type="hidden" name="id_poi[]" class="id_poi" value="">

The value is also set dynamically in JavaScript.

After i add this input, this is my DOM: DOM

So, i can add many inputs on my form.

When i'll handle this array on Laravel, i just get the value of the last input of this array.

I'm testing in this way:

public function store() {
    var_dump(Input::all());
    return;
}

And i had this output:

测试后变种

What i'm doing wrong to fail to get the values in an array?

EDIT:

I had other element with the same name in my form, and i change it. But the problem isn't solved yet, when i submit the form, the elements added dynamically isn't sent to PHP. Resulting in the same output above.

inputs is hidden name edit. Example

name="id_poi[0]"
name="id_poi[1]"

Sory, my English not good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM