作爲一個L5新手,我有一個表單,我正在使用它來編輯數據。我有像上一個,下一個,第一個和最後一個鏈接,以獲取記錄和編輯它們。我正在使用表單模型綁定來查看錶單上的值。我的目的是使用相同的表單來添加新記錄,但由於我使用表單模型綁定,所有輸入元素都顯示出它們的值。我應該如何使用相同的表單添加新記錄?任何幫助,將不勝感激L5使用相同的表單進行存儲和更新
{!! Form::model($vehicle,['url' => '/pages/store']) !!}
<table style="width:650px; margin-left: 4px;" >
<tbody>
<tr>
<td>ID</td>
<td>Model</td>
<td>Brand</td>
<td>License Plate</td>
</tr>
<tr>
<td>{!! Form::text('id' ,null , ['readonly'], ['class' =>'textboxlong form-control', 'style'=>'height:23px;']) !!}</td>
<td>{!! Form::text('model' ,null ,['class' =>'textboxlong form-control', 'style'=>'height:23px;']) !!}</td>
<td>
{!! Form::select('brand', $brands, null, ['id'=>'brandBox', 'style' => 'width:150px;']) !!}
</td>
<td>{!! Form::text('licenseplate' ,null ,['class' =>'textboxlong form-control', 'style'=>'height:23px;']) !!}</td>
</tr>
</tbody>
</table>
<div id="buttoncontainer">
<a class="btn btn-default" href="{{ URL::to('pages/vehicleprocess/' . $first -> id) }}"><<</a>
@if($previous)
<a class="btn btn-default" href="{{ URL::to('pages/vehicleprocess/' . $previous) }}">PREVIOUS</a>
@endif
@if($next)
<a class="btn btn-default" href="{{ URL::to('pages/vehicleprocess/' . $next) }}">NEXT</a>
@endif
<a class="btn btn-default" href="{{ URL::to('pages/vehicleprocess/' . $last -> id) }}">>></a>
<a class="btn btn-default" id="add">EKLE</a>
{!! Form::submit('EDIT', array('class'=>'btn btn-primary')) !!}
{!! Form::submit('NEW RECORD', array('class'=>'btn btn-primary')) !!}
</div>
{!! Form::close() !!}
你想添加新的記錄沒有刷新或什麼? –
我想通過使用相同的表單添加一條新記錄。 – Tartar
爲什麼不用jquery調用ajax? –