I have a laravel form and some input number fields in it. I want to post the different values of the input fields to the controller.
{!! Form::open(['action' => 'ShoppingController@addProducts', 'method' => 'post']) !!}
@foreach($products as $product)
// some non important other data
<input type="number" class="form-control text-center" min="1" max="999" value="{{ $product->quantity }}">
@endforeach
{!! Form::submit('ShoppingCard', ['class' => 'btn btn-primary fa fa-angle-right']) !!}--}}
{!! Form::close() !!}
Okay now imagine I have 3 different products, so 3 different number inputs. Now I want to pass all the different number values from the user to the controller. Like an array. How can I do that?
Thanks for any help!
<input type="number" name="quantity[{{ $product->id }}]" class="form-control text-center" min="1" max="999" value="{{ $product->quantity }}">
In the controller the input quantity
will be an array, with the product id as key.