Confirm Before Deleting post in CAKEPHP
CONFIRM BEFORE DELETING POST IN CAKEPHP
In the controller, create a delete function:
<?php
class EmployeeController extends AppController
{
public function delete($id)
{
$this->Employee->delete($id);
$this->Session->setFlash(‘The Employee is deleted.’);
$this->redirect(array(‘action’=>’index’));
}
}
In the view page, write the following code:
<a href=”#” onclick=”return confirm(‘Are you sure you want to delete this Employee?’);”>Delete</a>

Post a Comment