当验证没有通过时,它会返回到带有表单的页面,显示所有错误。就我而言,这是一个很长的页面,最底部的表格和错误。我如何让它回到那个页面,但是有一个锚标签?因此,用户不必再次向下滚动即可查看表单和错误。
我的控制器中有这段代码:
public function store(Request $request)
{
// Validate request...
$this->validate($request, [
'content' => 'required',
]);
// Store new post..
在我看来,这是:
// Show errors if there are any
@if (isset($errors))
@foreach ($errors->all() as $error)
<em><p class="text-danger">{{ $error }}</p></em>
@endforeach
@endif
// Form goes here...
绝对不是Laravel-4 中自定义验证的显示错误消息的副本。在那个问题中甚至没有提到锚标签,这是这个问题最重要的部分。