Here’s my code:
function admin_delete($id = null){
$booking = $this->Booking->read(null, $id);
if($this->Booking->delete($id)) {
$this->Session->setFlash('Booking deleted');
$this->redirect(array('action'=>'index'));
}
}
and this doesn’t seem to work. I’ve been fiddling with this for ages trying different code etc, using del() as well, but nothing seems to work. The link on the delete button is perfect (eg.com/bookings/delete/id:23), but it just tries to reach the admin_delete.ctp view. which I’ve clearly asked it to ignore by the redirect.
What am I doing wrong?
my delete link in the view:
<?php echo $html->link('Delete', array('action'=>'admin_delete', 'id'=>$booking['Booking']['id']), null, 'Are you sure?');?>
HALP!
if you are using admin routing you can not call
'action'=>'admin_delete'directly, its'action'=>'delete', 'admin' => true