使用图标确认消息不适用于 postLink

Confirm message not working on postLink with icon

我需要一些关于在 CakePHP 3 中使用 FormHelper 创建的 postLink 的帮助。正常的 postLink 工作得很好,就像这样:

<?= $this->Form->postLink(__('Delete'), 
    ['action' => 'delete', $member->id],
    ['confirm' => __('Are you sure, you want to delete {0}?', $member->name)]) ?>

但是当我尝试使用超棒的字体图标/i-tag 而不是文本 link 时,确认消息不再显示。图标本身显示正确并且操作仍然正常,只是消息不起作用。

我使用以下帖子寻求帮助,但答案中的示例对我不起作用:

CakePHP equivalent of html code

CakePHP delete confirmation

我尝试了这两种方法:

<?= $this->Form->postLink('<i class="fa fa-trash"></i> ',
    ['action' => 'delete', $member->id], 
    ['escape' => false], 
    ['confirm' => __('Are you sure, you want to delete {0}?', $member->name)]) ?>


<?= $this->Form->postLink(
        $this->Html->tag('i', '', ['class' => 'fa fa-trash']), 
                    ['action' => 'edit', $member->id],
                    ['escape' => false],
                    ['confirm' => __('Are you sure you want to delete {0}?', $member->name)]); ?>

我对 CakePHP 还是很陌生,并试图在书中查找它,但这对我没有帮助。我还尝试了上面 SO links 中所示的确切语法,这似乎对其他一些人有用......但确认消息仍然对我不起作用。

我做错了什么?

escapeconfirm 选项应该在同一个数组中。函数 postLink() 看起来像这样:

postLink(string $title, mixed $url = null, array $options =[])

所以适合您的工作代码是:

<?= $this->Form->postLink('<i class="fa fa-trash"></i> ',
    ['action' => 'delete', $member->id], 
    [
        'escape' => false,
        'confirm' => __('Are you sure, you want to delete {0}?', $member->name)
    ]
) ?>