0
如何可以验证与像相同名称的多个输入:如何验证阵列中Laravel 5.4
{!! Form::number('amount[]', $item->amount, ['class'=>'form-control width_30', 'placeholder'=>'Amount']) !!}
在请求?
我才发现,它可以与数字验证阵列像
{!! Form::number('amount[1]', $item->amount, ['class'=>'form-control width_30', 'placeholder'=>'Amount']) !!}
{!! Form::number('amount[2]', $item->amount, ['class'=>'form-control width_30', 'placeholder'=>'Amount']) !!}
的方法,但我必须添加和动态删除领域,所以这种方法不会为我工作。
这是在我的要求规则的代码:
public function rules()
{
return [
//
'client'=>'required',
'product'=>'required|array',
'amount'=>'required|array',
'item_id' => 'required|array'
];
}
,当我用这个required|array
方法,它返回我一个错误:
ErrorException in HtmlBuilder.php line 65:
htmlentities() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\smk\resources\views\admin\sales\edit.blade.php)
您是否将数组保存在'$ item-> amount'中?如果是这样,那么我想这个问题在这里,'Form :: number('field_name','default_value')''预计'default_value'是一个字符串,也许你传入一个数组(在'$ item->金额') –