我有这个密码;

<?php echo $this->Form->postLink(__('Delete'),
            array('action' => 'delete', $homepage['Homepage']['ContentID']),
            array('class'=>'btn icon-plus'),
            __('Are you sure you want to delete # %s?', $homepage['Homepage']['ContentID'])); ?>

在显示文本“Delete”的地方,我想把twitter bootstrap css包中的垃圾桶图标放进去。但是当我这样做的时候;
<?php echo $this->Form->postLink(__('<i class="icon-trash"></i>')....

它只显示html而不是抓取图标。
有人能解释一下为什么要这么做吗?我该怎么解决?

最佳答案

'escape' => false选项添加到第三个参数。

<?php echo $this->Form->postLink(__('Delete'),
            array('action' => 'delete', $homepage['Homepage']['ContentID']),
            array('class'=>'btn icon-plus', 'escape' => false),
            __('Are you sure you want to delete # %s?', $homepage['Homepage']['ContentID'])); ?>

关于html - CakePHP和Twitter Bootstrap CSS按钮图标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13004567/

10-10 05:47