Reputation: 1101
I'm having troubles sending a multidimentional array from my view to controller, actually I have this array:
$array_data[$i] = ['providers_id'=>$chosen_providers[$i],'buy_prices'=>$buy_prices[$i],'total'=>$total;
];
How can I send this to my controller?
I tried:
{{ Form::hidden('array_data[]',$array_data[$i]) }}
But I got htmlentities() expects parameter 1 to be string, array given error
Regards
Upvotes: 1
Views: 1188
Reputation: 273
You can pass your array using serialize()
. and then unserialize() the value in your controller.
view:
<input type="hidden" name="test" value="{{ serialize($arr) }}">
controller:
dd(unserialize($request->test));
Upvotes: 2
Reputation: 312
Don't know much about laravel functions if there any other to pass array...
but here you can convert that array to string or json and in the controller you and decode again that to array.
Upvotes: 0