问题
in controller i'm using:
if ($validator->fails())
{
return Redirect::to('/admin/profile')
->withErrors($validator)
->withInput();
}
how to get result of withErrors in view ?
{{ $errors->all() }}
回答1:
If you want to show all errors in one place you can use
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
If you want to show each field's errors e.g. bellow the field you can use (e.g. for email)
{{ $errors->first('email') }}
we use first() in order to show only one error each time for each field.
来源:https://stackoverflow.com/questions/22244442/laravel-get-result-of-witherrors-in-view