When editing form in laravel I cannot view the values being passed on the form. When i inputted values it successfully added to the table. However when I want to edit the values, they are not visible. However when I call the value outside the inputs form I can view the value.
See my code below.Can someone please help me. Thank you.
create.blade.php
<div class="panel-heading">
<h3 class="panel-title">New Report Form</h3>
</div>
<div class="panel-body">
@include('errors.list')
@include('partials.success')
{!! Form::open(['route'=>'crime_reports.store','class'=>'form-horizontal']) !!}
@include('crimereports._form')
<div class="form-group">
<div class="col-md-7 col-md-offset-3">
{!! Form::submit('Save Changes', ['class'=>'btn btn-primary btn-md']) !!}
<i class="fa fa-save"></i>
</div>
</div>
{!! Form::close() !!}
</div>
<div class="panel-footer ">
<p><small>Crime Chase</small></p>
</div>
edit.php
{!! Form::model('$crime_edit',['method' => 'PATCH','route'=>['crime_reports.update',$crime_edit->id],
'class'=>'form-horizontal']) !!}
@include('crimereports._form')
<div class="form-group">
<div class="col-md-7 col-md-offset-3">
{!! Form::submit('Update Form', ['class'=>'btn btn-primary btn-md']) !!}
</div>
</div>
{!! Form::close() !!}
</div>
<div class="panel-footer ">
<p><small>Crime Chase</small></p>
</div>
crimereportcontroller
public function store(CrimeNewReportRequest $request)
{
$input = $request->all();
CrimeReport::create($input);
// $input = CrimeReport::create($request->all());
// return redirect('crime_reports')->withSuccess("Fields were inserted!");
return redirect()->back();
}
public function edit($id)
{
$crime_edit = CrimeReport::findOrFail($id);
return view('crimereports.edit',compact('crime_edit',$crime_edit));
}
_form
<div class="form-group">
{!! Form::label('crime_victim', 'Victim Name',['class'=>'col-md-3 control- label']) !!}
<div class="col-md-8">
{!! Form::text('crime_victim', null, ['class' => 'form-control',
'placeholder' => 'Enter Victim name']) !!}
</div>
<div class="form-group">
{!! Form::label('crime_suspect', 'Suspect Name',['class'=>'col-md-3 control-label']) !!}
<div class="col-md-8">
{!! Form::text('crime_suspect', null, ['class' => 'form-control',
'placeholder' => 'Enter Suspect Name']) !!}
</div>
<div class="form-group">
{!! Form::label('suspect_description','List Description' ,['class'=>'col-md-3 control-label']) !!}
<div class="col-md-8">
{!! Form::textarea('suspect_description', null, ['class'=>'form-control',
'placeholder'=>'Details about suspect']) !!}
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire