I have the following link to a delete function in cake:
<?php echo $this->Form->postLink(__(''), array('action' => 'delete', $website['Website']['website_id']), array('class' => 'icon-trash '), null, __('Are you sure you want to delete # %s?', $website['Website']['website_id'])); ?>
Now as you can see there should be a message saying: Are you sure you want to delete?
But when i click the link nothing happens (exepect from my field being deleted ofcourse :P )
So how can i make the link display a confirmation box?
This will work
<?php echo $this->Form->postLink(__('Delete'), array(
'action' => 'delete', $website['Website']['website_id']), array(
'class' => 'icon-trash'
), __('Are you sure you want to delete # %s?', $website['Website']['website_id'])); ?>
You need to add code in below structure,
echo $this->Html->link(
'Delete',
array('action' => 'delete', $website['Website']['website_id']),
array(),
"Are you sure you wish to delete this recipe?"
);
Because of this, you're now passing five arguments.
Remove the null
and it should work;
echo $this->Form->postLink(
// title
__('delete'),
// URL
array('controller' => 'documents', 'action' => 'delete', $document['id']),
// Options
array('escape' => false),
// confirmMessage
__('Are you sure you want to delete # %s?', $document['file'])
); See the documentation; FormHelper::postLink()
hope this will sure help you.