hi i have a table of records where there's a delete link for every row.Her you will find cakephp for the delete action :
public function delete($id){
if ($this->request->is('get')) {
throw new MethodNotAllowedException();
}
if ($this->Category->delete($id)) {
$this->Session->setFlash( 'Votre élément a été supprimé.','default',array(),'success');
return $this->redirect(array('action' => 'index'));
}
}
so when i click on the delete button a raw javascript confirm dialog box is diplayed to confirm the action of the deletion in the view. here's an index.ctp containing the delete link :
<!--table content-->
<table class="table table-striped table-condensed table-bordered">
<tr>
<th>title</th>
<th>Actions</th>
</tr>
<?php foreach ($categorys as $category): ?>
<tr>
<td><?php echo $category['Category']['title']; ?></td>
<td>
<?php
echo $this->Html->link('View',
array('controller' => 'categories', 'action' => 'view', $category['Category']['id']),
array('class' => 'btn btn-info btn-sm active')
); ?>
<?php
echo $this->Html->link(
'Edit', array('action' => 'edit', $category['Category']['id']),
array('class' => 'btn btn-primary btn-sm active')
);
?>
<?php
echo $this->Form->postLink(
'Delete',
array('action' => 'delete', $category['Category']['id']),
array('confirm' => 'Do you want really to delete thi element?','class' => 'btn btn-danger btn-sm active')
);
?>
</td>
</tr>
<?php endforeach; ?>
<?php unset($category); ?>
</table>
so for the postlink i want when i click on the link it will show me a bootstrap confirmation modal like this :
<!-- Modal -->
<div class="modal fade" id="ConfirmDelete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Category deletion</h4>
</div>
<div class="modal-body">
Do you really want to delete thi element?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<a class="btn btn-danger danger">Confirm</a>
</div>
</div>
</div>
</div>
can someone help me to use the jshelper of the cake php to create a bootstrap modal dialog instead of the default one.
Thank you.