0

I use withErrors() to pass validation messages in template blade:

if ($validator->fails()) { dd($validator); // Gives me filled array with messages return Redirect::back() ->withErrors($validator) ->withInput(); 

In template I have:

@if (count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif 

I am guess that problem in the call stack of templates blade, or in function withErrors.

If withErrors uses session, maybe this is one of problem.

Additionally this is my call validation:

$validator = Validator::make($request->all(), [ "name" => 'required|string|min:10', "text" => 'required|string|min:10', ]); 
6
  • In view page what is the output of dd($errors) Commented Aug 5, 2016 at 18:14
  • ViewErrorBag {#255 ▼ #bags: [] } Commented Aug 5, 2016 at 18:15
  • please try dd($errors->toArray()) Commented Aug 5, 2016 at 18:17
  • So no error is passed to view. May be no validation error(double check). You may also laravel error log in storage/log directory because it seems that you are doing right. Commented Aug 5, 2016 at 18:35
  • 2
    Possible duplicate of ErrorBag is always empty in Laravel 5.2 Commented Aug 5, 2016 at 18:41

1 Answer 1

1

Try this in view:

@if(Session::has('error')) {{ Session::get('error') }} @endif 
Sign up to request clarification or add additional context in comments.

1 Comment

No result, again empty

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.