Laravel4 redirect withInput()填充字段失败


Laravel4 redirect withInput() fails to populate fields

当我重定向到页面时,它无法填充输入字段。

if ($validator->fails()){
            return Redirect::to('books/create')->with('message_warning','<strong>Warning!</strong> some input is not valid.')->withErrors($validator)->withInput();
        }else{
            $book->save();
            return Redirect::action('BooksController@index')->with('message_success','<strong>Awesome!</strong>Your book has been successfully added.');
        }

Input::old()工作于重定向。

形式摘录

{{  Form::open(array('action' => 'BooksController@store', 'method' => 'post', 'role'=> 'form')) }}
    <div class="form-group">
    <label for="title">Title</label>
    <input type="text" name="title" class="form-control" id="title" placeholder="Name of awesome book?">
  </div>

您必须使用旧的输入指定值。

<input type="text" name="title" value="{{ Input::old('title') }}">