下面是我的验证码。
$rules = [
'other_feature[]' => required
];
$message = [
'other_feature[].required' => 'The other feature field is required.',
];
$this->validate($request, $attributes_validation, $attributes_message);
$result = $this->UploadRepo->updateUploadValue($data,$id);
<_>在other_feature中传递多重选择值,如。
<select name='other_feature[]' multiple>
<option>First</option>
<option>Second</option>
<option>Third</option>
<option>Four</option>
<option>Five</option>
</select>
我在验证中创建了一个错误,为什么每次即使我选择值也会触发空验证,请帮忙。
由于
答案 0 :(得分:1)
我认为你应该放弃它[]
它没用。根据请求,您只需获得多个选定选项的数组,因此您无需将括号留在那里。你可以做的是验证它是否为数组。
$rules = [
'other_feature' => 'required|array'
];
$message = [
'other_feature.required' => 'The other feature field is required.',
];