2015-04-17 64 views
0

我想在我的索引中添加glyphicons而不是文本,添加,编辑视图。cakePHP 3.0和bootstrap glyphicons

这个作品在index.ctp

<?= $this->Html->link(__('<i class="glyphicon glyphicon-pencil"></i>'), ['action' => 'edit', $user->user_id], array('escape' => false)) ?> 

但是,当我的删除操作做它为我glyphicon,但它不给我“你确定要删除用户?

<?= $this->Form->postLink(__('<i class="glyphicon glyphicon-minus"></i>'), ['action' => 'delete', $user->user_id], array('escape' => false), ['confirm' => __('Are you sure you want to delete {0}?', $user->username)]) ?> 

在view.ctp中,它打破了之后出现的代码,所以后面的内容没有出现。 (在这个例子是这样的glyphicon铅笔后的内容。该glyphicon铅笔本身不作为好。

<?= $this->Html->link(__('<i class="glyphicon glyphicon-pencil'), ['action' => 'edit', $user->user_id], ['escape' => false]) ?> 

回答

4

采取在要传递的参数仔细一看,你逝去的4,其中该方法只接受3,即confirm选项不实际的参数选项中传递。

正确的格式有很大帮助发现这样的错误。

<?= 
$this->Form->postLink(
    __('<i class="glyphicon glyphicon-minus"></i>'), 
    [ 
     'action' => 'delete', 
     $user->user_id 
    ], 
    [ 
     'escape' => false, 
     'confirm' => __('Are you sure you want to delete {0}?', $user->username) 
    ] 
) 
?> 

和你FormHelper::link()例如缺少一个右双引号为<i>个元素class属性,以及对自身

'<i class="glyphicon glyphicon-pencil"></i>' 

你需要更加注重细节,这些问题在那里真的很简单,易于避免元素的结束标记。