1

Situation
I have a form where I can update certain records in the database and delete them. The form is located in a view and I handle the postrequest in the controller.

Question
How can use 2 seperate postrequest in one form? I need one for updating the form and one for removing certain records.

Code - View

 <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">&times;</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>

Code - Controller

    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;
        }
    }
Borgtex
  • 3,235
  • 1
  • 19
  • 28
Mike Lammers
  • 542
  • 9
  • 27

0 Answers0