When validation doesn't pass, it goes back to the page with the form, displaying all errors. In my case, that's a very long page, with the form and errors at the very bottom. How do I let it go back to that page, but with an anchor tag? So the user wouldn't have to scroll down again to see the form and the errors.
I have this code in my controller:
public function store(Request $request)
{
// Validate request...
$this->validate($request, [
'content' => 'required',
]);
// Store new post..
And this in my view:
// 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...
Definitly not a duplicate of Display Error Message For Custom Validation In Laravel-4. In that question anchor tags aren't even mentioned, the most important part of this question.