Cakephp链接提醒

时间:2013-08-26 09:08:26

标签: php cakephp

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

    <?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)

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

3 个答案:

答案 0 :(得分: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'])); ?>

答案 1 :(得分:1)

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

echo $this->Html->link(
    'Delete',
    array('action' => 'delete', $website['Website']['website_id']),
    array(),
    "Are you sure you wish to delete this recipe?"
);

答案 2 :(得分: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()

希望这对您有所帮助。