场合
我有一个表单,我可以更新数据库中的某些记录并删除它们。表单位于视图中,我在控制器中处理postrequest。
问题
如何在一种形式中使用2个单独的postrequest?我需要一个用于更新表单,一个用于删除某些记录。
代码 - 查看
<form class="form-horizontal col-md-8" method="post" action="{$URL_FULL}" id="frmMarkerList">
<input type="hidden" name="postrequest" value="updateMarkers">
<input type="hidden" name="postrequest" value="deleteMarkers">
<input type="hidden" name="mk_UUId" value="{$aCoords.Marker_UUId}">
<table class="table table-hover" id="tblMarkers">
<thead>
<tr>
<th class="col-md-10">Coordinaten</th>
</tr>
</thead>
<tbody> {*'Marker_Id','Marker_UUId','Markercat_Id','Lat','Lng','Titel','Url'*}
{foreach $aCoords|default:array() as $mk_coords} {*'Woning_Id','Woning_UUId','Projectwoning_Id','Projectwoning_Titel','Project_Id','Project_Titel','Woning_Bouwnr'*}
<tr id="row_{$mk_coords.Marker_Id}">
<td class="td-shapes">
<strong>Lat:</strong>
<input type="text" class="coord" name="Coords[{$mk_coords.Marker_Id}]" data-wid="{$mk_coords.Marker_Id|escape}" value="{$mk_coords.Lat|escape}" style="width: 250px;margin:4px 0 0 0">
<strong>Lng:</strong>
<input type="text" class="coord" name="Coords[{$mk_coords.Marker_Id}]" data-wid="{$mk_coords.Marker_Id|escape}" value="{$mk_coords.Lng|escape}" style="width: 250px;margin:4px 0 0 0">
</td>
<td>
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button> {*This is the delete request button*}
</td>
</tr>
{/foreach}
</tbody>
</table>
<input type="submit" class="btn btn-primary" value="Bijwerken"> {*This is the update request button*}
</form>
代码 - 控制器
if($this->getRequest()->getPost('postrequest')){
//verwerk request eerst
switch($this->getRequest()->getPost('postrequest')){
case 'updateMarker':
var_dump($aCoords);
break;
case 'deleteMarker':
var_dump($aCoordsCat);
break;
default:
break;
}
}