Php Laravel 5.1:无法显示$errors->;模板中的第一个

Php Laravel 5.1:无法显示$errors->;模板中的第一个,php,laravel,laravel-5,laravel-5.1,Php,Laravel,Laravel 5,Laravel 5.1,我有以下html: <div class="form-group @if( $errors->has('question') ) has-error has-feedback @endif "> <label for="question" class="col-md-4 control-label">Question</label> <div class="col-md-6"&

我有以下html:

    <div class="form-group
      @if( $errors->has('question') )
        has-error has-feedback
      @endif
    ">
    <label for="question" class="col-md-4 control-label">Question</label>
    <div class="col-md-6">
     <input type="text" class="form-control c-square c-theme"
       id="Idquestion" name="question" value="{{Request::old('question')}}" placeholder="question text" >
   @if ($errors->has('question'))
      <span class="glyphicon glyphicon-remove form-control-feedback">
   {!! $errors->first('question') !!}
     </span>
  @endif

  <?php echo 'PHP ERRORS: '. print_r ($errors->first('question')) ; ?>
   @if( $errors->has('question'))
     <span class="glyphicon glyphicon-remove form-control-feedback">
     {{ $errors->first('question') }}
     </span>
  @endif
    </div>
  </div>

 <div class="form-group">
  <label for="answer" class="col-md-4 control-label">Answer</label>
  <div class="col-md-6">
    <input type="text" class="form-control c-square c-theme" id="Idanswer" name="answer" placeholder="input">
    </div>
 </div>
有人能告诉我我做错了什么以及如何纠正吗

拉威尔误差包 表单名称可以传递到错误的
MessageBag
,允许您检索特定表单的错误消息

将名称作为第二个参数传递给
withErrors

return redirect('viewName')->withErrors($validator, 'formName');
视图(刀片)中,您可以使用以下名称访问
消息包

{{ $errors->formName->first('formFieldName') }}
请记住,在first()中传递字段的名称。。 检查是否有名为“问题”的表单元素

参考文件

希望这有帮助。

试试这个

在你的刀片上有下面的链接

 <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
            <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }} control-required">
            {!! Form::label('title', 'Title') !!}<span class="mand_star"> *</span>
                {!! Form::text('title', isset($news->title) ? $news->title : \Input::old('title'), [
                    'class'       => 'form-control',
                    'placeholder' => 'News Title',
                    'required'    => 'required'
                ]) !!}
               <span class="error_span"> {{ $errors->first('title') }}</span>
            </div>
        </div>
它适用于所有单个输入字段,也会填充该字段中的旧数据

希望能有帮助

{{ $errors->formName->first('formFieldName') }}
 <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
            <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }} control-required">
            {!! Form::label('title', 'Title') !!}<span class="mand_star"> *</span>
                {!! Form::text('title', isset($news->title) ? $news->title : \Input::old('title'), [
                    'class'       => 'form-control',
                    'placeholder' => 'News Title',
                    'required'    => 'required'
                ]) !!}
               <span class="error_span"> {{ $errors->first('title') }}</span>
            </div>
        </div>
if ($validation->fails()) {
            return redirect()->route('your route path')->withErrors($validation)->withInput();
        }