I've never tried name="new[]" for input field. For checkbox it works. What happens if you remove 2. input and just put name="new" for the first input?
Dec 10, 2019
5
Level 1
validate array with inputs (text) not work
Hi. I have problem with validate html input array. I have something like this:
<td colspan="2">
<div class="form-check">
{!! Form::checkbox('car', null, false, ['class'=>'form-check-input']); !!}
<label class="form-check-label" for="defaultCheck1">Car</label>
</div>
</td>
<td>
<div class="form-inline">
<label class="form-check-label" for="defaultCheck1">1.</label>
<input class="form-control form-control-sm" style="width: 98%" type="text" name="new[]"/>
</div>
<div class="form-inline">
<label class="form-check-label" for="defaultCheck1">2.</label>
<input class="form-control form-control-sm" style="width: 98%" type="text" name="new[]"/>
</div>
</td>
...
$request->validate([
'new' => ['required_if:car,on', 'array', 'min:1'],
]
This validate not work. When Checkbox is not selected if nothing happen. Is this correct way to valdiate array with inputs (type text)?
Please or to participate in this conversation.