This is weird. I've been googling all day trying to find a solution for my problem and most of solutions don't work for me due to different versions or different request - controller handling.
What's happening is this.
I have a form:
<div class="form-group">
Name *
{!! Form::text('name', '', ['class'=>'form-control', 'placeholder'=>'Required field']) !!}
</div>
And a Request:
class ContactFormRequest extends Request
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required|max:64',
'email' => 'required|email|max:128',
'message' => 'required|max:1024',
];
}
}
I'm leaving the name field blank so it fails validation, and it should return to the contact form page and show the errors:
@if(count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
It shows nothing! If I vardump
the $errors
variable, I get this:
object(Illuminate\Support\ViewErrorBag)[161]
protected 'bags' =>
array (size=0)
empty
If I fill the form field properly it successfully sends me to the success page and everything works perfect. All I need now is to make this error thing work properly :S
Thank you in advance!