Support the ongoing development of Laravel.io →
Validation

This is the problem that I encounter Undefined variable: errors (View: /var/www/html/laravel.com/resources/views/idsi/new1.blade.php) Thanks in advance for helping.

            $this->validate($request, [
            'empid' => 'required|empid|unique:employees',
            'sname' => 'required|max:100',
            'fname' => 'required|max:100',
            'mname' => 'required|max:100',
            'nname' => 'required|max:100',
            ]);
            @if(count($errors) > 0)
		<div class="row">
			<div class="col-md-6">
				<ul>
					@foreach($errors->all() as $error)
					      <li>{{$error}}</li>
					@endforeach
				</ul>
			</div>
		</div>
	@endif
Last updated 3 years ago.
0

For Laravel 5.2 make sure any routes where you will end up rendering a view that wants access to $errors that the 'web' middleware group is applied.

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.