我用来withErrors()
在模板刀片中传递验证消息:
if ($validator->fails()) {
dd($validator); // Gives me filled array with messages
return Redirect::back()
->withErrors($validator)
->withInput();
在模板中,我有:
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
我猜这是模板Blade的调用堆栈或function中的问题withErrors
。
如果withErrors
使用会话,也许这是问题之一。
另外,这是我的电话验证:
$validator = Validator::make($request->all(), [
"name" => 'required|string|min:10',
"text" => 'required|string|min:10',
]);
尝试以下方法:
@if(Session::has('error'))
{{ Session::get('error') }}
@endif
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句