I am so confused, I am learning Laravel from Laracast, according to the instructor, after the verification failed, the form did not enter reset the values ββentered by the user. But when checking validation, when I submit the reset form every thing.
Another question is the undefined $errors variable when I try to access it.
My controller
<?php namespace App\Http\Controllers; use App\Articles; use App\Http\Requests\CreateArticle; use Carbon\Carbon; use App\Http\Requests; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class ArticlesController extends Controller { public function create() { return view('articles.create'); } public function store(Request $request) { $this->validate($request, [ 'title' => 'required', 'body' => 'required' ]); Articles::create($request->all()); return redirect('articles'); } }
My view
@extends('app') @section('content') <h1>Create a new Articles</h1> <hr/> {!! Form::open(['url' => 'articles']) !!} <div class="form-group"> {!! Form::label('title', 'Title: ') !!} {!! Form::text('title', null, ['class' => 'form-control']) !!} </div> <div class="form-group"> {!! Form::label('body', 'Body') !!} {!! Form::textarea('body', null, ['class' => 'form-control']) !!} </div> <div class="form-group"> {!! Form::label('published_at', 'Published On:') !!} {!! Form::input('text', 'published_at', date('Ym-d'), ['class' => 'form-control']) !!} </div> <div class="form-group"> {!! Form::submit('submit', ['class' => 'btn btn-primary']) !!} </div> @if(isset($errors)) {{var_dump($errors)}} @endif {!! Form::close() !!} @stop
It uses v5.0 and I use v5.2
source share