Let I have 3 fields in the form.
I write this code for form validation.
$rules = array(
'field_1' => 'required',
'field_2' => 'required',
'field_3' => 'required',
);
$messages = array(
'field_1.required' => 'Please fill up all value',
'field_2.required' => 'Please fill up all value',
'field_3.required' => 'Please fill up all value',
);
$validator = Validator::make(Input::all(), $rules, $messages);
Now if user fill up the form 2 fields with blank then the validator return two error message. If user fill up the form 3 fields with blank then the validator return three error message. But I want to show only one message for all fields.
you could change it to
$messages = array(
'required' => 'Please fill up all value',
);
validator = Validator::make(Input::all(), $rules, $messages);
and let your view only output the first error message.
{{ $errors->first(null,'<div class="alert alert-danger">:message</div>') }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With