我想为我的编辑表单制作模态弹出窗口。我已经制作了弹出窗口,但它不会得到id
。
这是我的视角:
<a title='Edit Data' href="#" data-toggle="modal" class='btn btn-xs btn-warning' data-target="#moModal"><i class='fa fa-pencil'></i></a>
和我的模态:
<div class="modal fade" id="moModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<center><h4>Edit</h4></center>
</div>
<div class="modal-body">
<form method='post' action='{{action("FacilitiesController@postEditSave")."/$row->id"}}' enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="box-body">
<div class="box-body">
<div class='form-group col-sm-6'>
<label>Facilities</label>
<input type='text' class='form-control' name='name_facility' value='{{ $row->name_facility }}' required/>
</div>
<div class='form-group col-sm-12'>
<button type='submit' class='btn btn-primary'><i class='fa fa-save'></i> Simpan</button>
</div>
</div><!-- /.box -->
</form>
</div>
</div>
</div>
</div>
这是我的控制器:
public function getIndex()
{
$posts = DB::table('facilities')
->orderBy('id', 'asc');
$posts = $posts->paginate(10);
return view('facilities', ['posts' => $posts]);
}
public function getEdit($id) {
$data['row'] = facilities::find($id);
return view('facilities_form',$data);
}
public function postEditSave($id) {
$simpan= array();
$simpan['name_facility']=Request::input('name_facility');
DB::table('facilities')->where('id', $id)->update($simpan);
Session::flash('edit', 'Data successfully edited');
return Redirect::to('facilities');
}
那么,有人帮助我,我必须对代码做出哪些改进才能实现我的目标?