I have a form with dynamics rows. I would like to use FormRequest to validate data rows. How to achieve it ?
Form
<td>
<input class="form-control form-control-sm" id="item_quantity" type="number" step="any" min="0" name="item_quantity[]" value="{{old('item_quantity[]')}}">
{!!$errors->first('item_quantity', '<span class="error">:message</span>')!!}
</td>
My FormRequest Code :
public function rules()
{
return [
'item_quantity' => 'required'
];
}
1: Do you save it as array or per row?
you can pass only required data as validated by form by adding required at end of input.
if this does not work, please lets know how you save your data as per question 1 above.