0
我用withErrors()
通過模板刀片驗證消息:爲什麼不能在Laravel中使用錯誤?
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
我想在模板調用堆棧問題刀片,或在功能上withErrors
。
如果withErrors
使用會話,也許這是問題之一。
此外,這是我的電話驗證:
$validator = Validator::make($request->all(), [
"name" => 'required|string|min:10',
"text" => 'required|string|min:10',
]);
鑑於頁面是什麼DD的輸出($錯誤) –
'ViewErrorBag {#255▼ #包:[] }' – Dev
請嘗試dd($ errors-> toArray()) –