1

我有以下链接到蛋糕中的删除功能:

    <?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'])); ?>

现在你可以看到应该有一条消息说:Are you sure you want to delete?

但是当我点击链接时,什么也没有发生(当然我的字段被删除了:P)

那么如何让链接显示一个确认框呢?

4

3 回答 3

2

这将起作用

<?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'])); ?>
于 2013-08-26T09:11:41.097 回答
1

您需要在以下结构中添加代码,

echo $this->Html->link(
    'Delete',
    array('action' => 'delete', $website['Website']['website_id']),
    array(),
    "Are you sure you wish to delete this recipe?"
);
于 2013-08-26T09:16:20.177 回答
1

因此,您现在要传递五个参数。

删除null它,它应该可以工作;

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'])

); 请参阅文档;FormHelper::postLink()

希望这对你有帮助。

于 2013-08-26T09:18:26.453 回答