I have an array of checkboxes including a hidden checkbox so i can send a value 0 if a checkbox is not checked.
@foreach($records as $record)
<tr>
<td></td>
<td></td>
<td>
<input type="hidden" name="record_checkbox[]" value="0" />
<input type="checkbox" class="form-control name="record_checkbox[]" value="1" />
</td>
</tr>
@endforeach
So i now want to validate that only 0 or 1 is sent when user submits the form.
So in my controller i have tried using this:
$this->validate($request, [
'record_checkbox[]' => 'integer|boolean|min:0|max1:',
]);
But still when i use the chrome console and manually update the value field of checkbox to say 100 then it still accepts it and stores it in database.
So how can i only allow 0 or 1 by proper validation ?
Aucun commentaire:
Enregistrer un commentaire