This is the code where I need to set the value for the label :
{!! Form::label('unit',$value=$fileN) !!}
When I coded that it will display the following error.
ErrorException in UploadController.php line 51: Undefined index: unit
I changed that to {{ Form::label('unit', $fileN) }}. But above same error will display. Below is the output.
<label for="unit">rainforest.pdf</label>
Controller method look likes below.
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() !!}
Can anybody help me that out?
答案 0 :(得分:0)
您的标签声明错误,而不是:
{!! Form::label('unit',$value=$fileN) !!}
应该是:
{{ Form::label('unit', $fileN) }}
您收到错误Undefined index: unit
,因为您没有名称为unit
的任何字段,而您正试图将其捕获:
$unit = $_POST['unit'];
您可以使用隐藏字段发送单位值,如:
{!! Form::hidden('unit',$fileN) !!}
希望这有帮助。