这给了我我想要的东西:
<?php echo $this->Html->link(
$this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-edit')) . " Edit",
array('action' => 'edit', $comment['Comment']['comment_id']),
array('class' => 'btn btn-mini', 'escape' => false)
); ?>
但是,当我创建一个表单postLink时,我不知道如何在其前面添加删除图标。
<?php echo $this->Form->postLink(
$this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')) . " Delete",
array('action' => 'delete', $comment['Comment']['comment_id']), null, __('Are you sure you want to delete # %s?', $comment['Comment']['comment_id']),
array('class' => 'btn btn-mini', 'escape' => false)
); ?>
它给了我
<i class="glyphicon glyphicon-remove"></i> Delete
最佳答案
您忘记将选项escape
添加到false
echo $this->Form->postLink(
$this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')). " Delete",
array('action' => 'delete', $comment['Comment']['comment_id']),
array('escape'=>false),
__('Are you sure you want to delete # %s?', $comment['Comment']['comment_id']),
array('class' => 'btn btn-mini')
);
关于forms - 如何使用cakephp和twitter bootstrap 在表单poSTLink中创建图标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22995651/