Laravel 5 设置laravel 5表单中输入标签的值

Laravel 5 设置laravel 5表单中输入标签的值,laravel-5,Laravel 5,这是我需要设置标签值的代码: {!! Form::label('unit',$value=$fileN) !!} 当我编码时,它将显示以下错误 UploadController.php第51行出现错误异常: 未定义索引:单位 我将其更改为{{Form::label('unit',$fileN)}。但上面同样的错误会显示出来。下面是输出 <label for="unit">rainforest.pdf</label> rainforest.pdf 控制器方法如下所示

这是我需要设置标签值的代码:

{!! Form::label('unit',$value=$fileN) !!}
当我编码时,它将显示以下错误

UploadController.php第51行出现错误异常: 未定义索引:单位

我将其更改为{{Form::label('unit',$fileN)}。但上面同样的错误会显示出来。下面是输出

<label for="unit">rainforest.pdf</label>
rainforest.pdf
控制器方法如下所示

public function edit1()
{

    $grade = $_POST['grade'];
    $subject = $_POST['subject'];
    $id = $_POST['id'];
    $title = $_POST['title'];
    $unit = $_POST['unit'];
    $uplds = Upldtbl::findOrFail($id);


    DB::table('upldtbls')
        ->where('id', $id)
        ->update(['title' => $title, 'subject' => $subject,'url' => $unit, 'grade' => $grade]);


    return redirect('/hgh');
}


{!! Form::open(array('url'=>'hgh1','method'=>'POST', 'files'=>true, 'class'=>'upldform')) !!}
                                    <table>
                                        <div class="control-group">
                                              <div class="controls">
                                                  <tr>

                                                         <td> <b>{!! Form::label('Grade', 'Grade') !!}</b></td>

                                                         <td> {!! Form::select('grade', array('Grade' => 'Grade','2' => '2', '3' => '3','4' => '4'), $value=$grade) !!}</td>

                                                   </tr>
                                                   @if(Session::has('errorUpldGrade'))
                                                      <tr>
                                                          <td><ul class="alert alert-danger" style="width: 250px;height: 40px">{!! Session::get('errorUpldGrade') !!}</ul></td>
                                                      </tr>
                                                   @endif

                                                   <tr>

                                                       <td><b>{!! Form::label('Subject', 'Subject') !!}</b></td>
                                                       <td>{!! Form::select('subject', array('Subject' => 'Subject','English' => 'English', 'Mathematics' => 'Mathematics','Environmental Studies' => 'Environmental Studies'), $value=$sub) !!}</td>
                                                   </tr>
                                                   @if(Session::has('errorUpldSubj'))
                                                      <tr>
                                                          <td><ul class="alert alert-danger" style="width: 250px;height: 40px"><p class="errors">{!! Session::get('errorUpldSubj') !!}</p></ul></td>
                                                      </tr>
                                                   @endif

                                                   <tr>
                                                       <td> <b>{!! Form::label('Title', 'Title') !!}</b></td>
                                                       <td>  {!! Form::text('title',$value=$title) !!}</td>
                                                   </tr>


                                                   @if(Session::has('errorUpldTitle'))
                                                      <tr>
                                                          <td><ul class="alert alert-danger" style="width: 250px;height: 40px"><p class="errors">{!! Session::get('errorUpldTitle') !!}</p></ul></td>
                                                      </tr>
                                                   @endif

                                                      <tr>

                                                          <td>{!! Form::file('image') !!}{{ Form::label('unit', $fileN) }}</td>
                                                          <td><p class="errors">{!!$errors->first('image')!!}</p></td>

                                                      </tr>
                                                     @if(Session::has('errorUpldFile'))
                                                      <tr>

                                                      <td><ul class="alert alert-danger" style="width: 250px;height: 40px"><p class="errors">{!! Session::get('errorUpldFile') !!}</p></ul></td>
                                                      </tr>
                                                     @endif
                                                     <td>{!! Form::hidden('id',$id ) !!}</td><br>
                                              </div>
                                         </div>


                                        <tr>
                                            <td> {!! Form::submit('Update', array('class'=>'send-btn')) !!}</td>


                                        </tr>
                                        </table>
                                        {!! Form::close() !!}
公共函数edit1()
{
$grade=$_POST['grade'];
$subject=$_POST['subject'];
$id=$_POST['id'];
$title=$_POST['title'];
$unit=$_POST['unit'];
$uplds=Upldtbl::findOrFail($id);
DB::table('upldtbls')
->其中('id',$id)
->更新(['title'=>$title,'subject'=>$subject,'url'=>$unit,'grade'=>$grade]);
返回重定向('/hgh');
}
{!!Form::open(数组('url'=>'hgh1','method'=>'POST','files'=>true,'class'=>'upldform'))
{!!Form::label('Grade','Grade')
{!!Form::select('grade',array('grade'=>'grade','2'=>'2','3'=>'3','4'=>'4'),$value=$grade)
@if(会话::has('errorUpldGrade'))
    {Session::get('errorUpldGrade')!!}
@恩迪夫 {!!Form::label('Subject','Subject') {!!表单::选择('subject',数组('subject'=>'subject','English'=>'English','Mathematics'=>'Mathematics','environment Studies'=>'environment Studies'),$value=$sub) @if(会话::has('errorUpldSubj'))

    {!!Session::get('errorUpldSubj')!!}

@恩迪夫 {!!Form::label('Title','Title') {!!Form::text('title',$value=$title)!!} @if(Session::has('errorUpldTitle'))

    {!!Session::get('errorUpldTitle')!!}

@恩迪夫 {!!Form::file('image')!!}{{{Form::label('unit',$fileN)}

{!!$errors->first('image')

@if(会话::has('errorUpldFile'))

    {!!Session::get('errorUpldFile')!!}

@恩迪夫 {!!Form::hidden('id',$id)!!}
{!!Form::submit('Update',array('class'=>'send-btn')) {!!Form::close()!!}

有谁能帮我解决这个问题吗?

您的标签声明有误,而不是:

{!! Form::label('unit',$value=$fileN) !!}
应该是:

{{ Form::label('unit', $fileN) }}
您将得到错误
未定义索引:unit
,因为您没有任何名为
unit
的字段,并且您正试图在以下位置捕获它:

 $unit = $_POST['unit'];
您可以使用隐藏字段发送单位值,如:

{!! Form::hidden('unit',$fileN) !!}

希望这有帮助。

您的标签声明错误,而不是:

{!! Form::label('unit',$value=$fileN) !!}
应该是:

{{ Form::label('unit', $fileN) }}
您将得到错误
未定义索引:unit
,因为您没有任何名为
unit
的字段,并且您正试图在以下位置捕获它:

 $unit = $_POST['unit'];
您可以使用隐藏字段发送单位值,如:

{!! Form::hidden('unit',$fileN) !!}

希望这有帮助。

然后它将显示此错误和以前的错误。rainforest.pdfDo单击“提交”按钮后是否出现此错误?请给我们看51行。这意味着您的问题不是标签。请尝试将完整表单添加到您的问题中。我在controller方法之后添加了表单。是的,这很有意义,您现在得到了错误,因为您没有任何名为
unit
的字段,并且您正试图在
$unit=$\u POST['unit']中捕获它。然后它将显示此错误和以前的相同错误。rainforest.pdfd你明白了吗