Laravel-通过POST将输入值传递给控制器

Laravel-通过POST将输入值传递给控制器,laravel,post,parameter-passing,user-input,Laravel,Post,Parameter Passing,User Input,我有一个laravel表单和一些输入数字字段。我想将输入字段的不同值发布到控制器 {!! Form::open(['action' => 'ShoppingController@addProducts', 'method' => 'post']) !!} @foreach($products as $product) // some non important other data <input type="number" class="fo

我有一个laravel表单和一些输入数字字段。我想将输入字段的不同值发布到控制器

 {!! 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() !!}
{!!Form::open(['action'=>'ShoppingController@addProducts“,”方法“=>”发布“])
@foreach($products as$product)
//一些不重要的其他数据
@endforeach
{!!表单::提交('ShoppingCard',['class'=>'btn btn primary fa fa angle right'])!!--}
{!!Form::close()!!}
好的,现在想象我有3种不同的产品,3种不同的数字输入。现在我想将所有不同的数值从用户传递到控制器。像一个数组。我该怎么做


谢谢你的帮助

尝试此操作,您将在控制器中获得一个数字数组

<input type="number" name="number[]" class="form-control text-center" min="1" max="999"     value="{{ $product->quantity }}">

尝试此操作,您将在控制器中获得一个数字数组

<input type="number" name="number[]" class="form-control text-center" min="1" max="999"     value="{{ $product->quantity }}">


在控制器中,输入的
数量将是一个数组,产品id为键。


在控制器中,输入的
数量将是一个数组,产品id作为键。

对于表单,请执行此操作

<input type="number" name="productid[]" class="form-control text-center" min="1" max="999"     value="{{ $product->quantity }}">
$value是表单执行此操作时每个输入的值

<input type="number" name="productid[]" class="form-control text-center" min="1" max="999"     value="{{ $product->quantity }}">

$value是每个输入的值

我将尝试它-我尝试了与之类似的东西,但使用了name=“quantity[]”-@WellNo抱歉,我现在修复了它,同时确保产品有一个
id
字段。我将尝试它-我尝试了与之类似的东西,但使用name=“quantity[]”-@WellNo抱歉,我现在修复了它,还要确保产品有一个
id
字段。是的,我也尝试过,但我的问题是产品本身和数量之间没有联系。。我想要1:50,2,15,其中1是产品ID,50是数量是的,我也尝试过,但我的问题是产品本身和数量之间没有联系。。我想要像1:50,2,15这样的东西-其中1是产品ID,50是数量-这是我尝试过的,它也起了作用,但我不喜欢这种方式,因为产品ID和数量之间没有联系。我想要像1:15一样的东西-1是id,15是数量我想你需要把你的问题弄清楚,因为你的要求并不明显-这是我尝试过的,它也起作用,但我不喜欢这种方式,因为产品id和数量之间没有联系。我想要像1:15那样的东西-1是id,15是数量我想你需要把你的问题说清楚,因为你要的不是显而易见的我会试试,给我一分钟:)我会试试,给我一分钟:)