2015-09-06 79 views
1

我需要一些帮助,在CakePHP中3.表单助手创建postLink正常postLink工作得很好这样的:确认消息图标

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

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

我用来帮助以下职位,但在答案的例子有没有工作对我来说:

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链接中显示的确切语法,它似乎为其他人工作...但确认消息仍然不适用于我。

我在这里做错了什么?

+0

可能重复http://stackoverflow.com/questions/29703597/ cakephp-3-0-bootstrap-glyphicons) – ndm

+0

谢谢,是的。如果我找到答案,那个问题的答案会帮助我...。但标题和标签有点误导,因为这个问题不是(仅)关于图标问题。我认为在这里建立一个确认信息问题的连接并不容易。 – eve

回答

2

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) 
    ] 
) ?> 
的[CakePHP的3.0和引导glyphicons(
+0

谢谢,那就是诀窍!我知道这是一件非常容易的事......但我不知道xD是什么。 – eve