php - Validation Radio Button Laravel 5.4
Hi this is courious I dont understand how I can validate a radio input, I have validated other inputs with laravel, but Radio no. Of course I am Laravel Beginner. When I don't filled the framework not give error to print. So formaPago is not validated. Cheers. This is the HTML:
<table >
<thead>
<tr>
@foreach($formasPago as $forma)
<th><div >
<label for="formaPago" ></label>
<input type="radio"
value="{{$forma->id}}"
name="formaPago" >{{$forma->nombre}}
</div></th> @endforeach
</tr>
</thead>
And the Validator in controller looks this way:
$validator = \Validator::make($request->all(), [
'nombreCompleto'=> 'required|string|max:255',
'email'=> Session::has('clientePotencial')?'required|string|email|max:255':'required|string|email|max:255|unique:users',
'celular'=> 'required',
'cedula'=> 'required',
'primaria'=> 'required',
'secundaria'=> 'required',
'referencia'=> 'required',
'formaPago'=> 'required|filled'
]);
Answer
Solution:
Set name attribute for radio button
get list of valid values and add below rule in validation