我正在使用Laravel 4.2和Bootstrap ...我正在尝试更新表中的数据,但每次我这样做,第一行都没有像其他行一样响应..这里是我的.blade.php文件。它扩展了一个masterlayout,这就是这个部分:
<form id="Car_Brand" >
<div class="panel panel-primary">
<div class="panel-heading">
Car Brands
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#modalAdd">Add</button></div>
<div class="panel-body">
<table id="table" class="table table-bordered table-responsive">
<thead>
<tr>
<th>Car Brand Id</th>
<th>Car Brand Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($carbrands as $cbrands)
@if($cbrands->status == 1)
<tr>
<td>{{ $cbrands->strCarBrandId }}</td>
<td>{{ $cbrands->strCarBrandDesc }}</td>
<td>
<button id="btn_edit" type="button" class="btn btn-info" data-toggle="modal" href="#edit{{ $cbrands->strCarBrandId }}">Edit</button>
<!-- Modal Edit -->
<div id="edit{{ $cbrands->strCarBrandId }}" class="modal fade" role="dialog">
<div class="modal-dialog">
<form action="/carbrandUp" method="post">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">EDIT</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label>Car Brand Id </label>
<input name="car_brand_id_edit" id="car_brand_id_edit" class="form-control" type="text" value="{{ $cbrands->strCarBrandId }}" readonly>
<label>Car Brand Name </label>
<input name="car_brand_name_edit" id="car_brand_name_edit" class="form-control" type="text" value="{{ $cbrands->strCarBrandDesc }}">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div><!-- Modal Edit -->
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
<div class="panel-footer">
</div>
</div>
</form>
这是我的路线:
Route::get('/CarBrand', "CarController@maintenanceCarbrand");
Route::post('/carbrandUp', array('uses'=>'CarController@updateCarbrand'));
这就是我的汽车控制器里面的东西:
public function maintenanceCarbrand()
{
$brands = MCarBrand::all();
return View::make('carbrandMaintenance')->with('carbrands', $brands);
}
public function updateCarbrand()
{
$id = Input::get('car_brand_id_edit');
$carbrand = MCarBrand::find($id);
$carbrand->strCarBrandDesc = Input::get('car_brand_name_edit');
$carbrand->save();
//dd($id);
return Redirect::to('/CarBrand');
}
我似乎无法在这里找到错误。请帮忙。非常感谢。