CakePHP相当于html代码 [英] CakePHP equivalent of html code
问题描述
我正在使用一个cakePHP项目,我需要使用PHP创建一个按钮,删除数据库中的一个条目,但我想在上述按钮上显示twitter bootstrap trashcan图标。
I am working on a cakePHP project and I need to create a button using PHP that will delete an entry in a database, but I want to display the twitter bootstrap trashcan icon on said button.
包含twitter启动图标的代码是
The code to include the icon from twitter bootstrap is;
<i class="icon-trash"></i>
我需要它的PHP代码是:
And the PHP code I need it to work in is;
<?php echo $this->Form->postLink(__('Delete'),
array(
'action' => 'delete',
$skill['Skill']['SkillID']),
array(
'class'=>'btn'),
null,
__('Are you sure you want to delete # %s?',
$skill['Skill']['SkillID']
));?>
有没有人知道如何实现html在这个PHP代码,所以我可以替换文本'具有图标?
Does anyone know how to implement the html in this PHP code so I can replace the text 'Delete' with the icon?
推荐答案
echo $this->Form->postLink(
'<i class="icon-trash"></i> '.__('Delete'),
array(
'action' => 'delete',
$skill['Skill']['SkillID']
),
array(
'class'=>'btn',
'escape' => false
),
null,
__('Are you sure you want to delete # %s?',
$skill['Skill']['SkillID'] )
);
'escape'=> false
使CakePHP显示HTML未转义。
'escape' => false
makes CakePHP display the HTML unescaped.
它可能(根据CSS)也工作,如果你只是添加 icon-trash
class to the link。
It might (depending on the CSS) also work if you just add the icon-trash
class to the link.
echo $this->Form->postLink(__('Delete'),
array(
'action' => 'delete',
$skill['Skill']['SkillID']),
array(
'class'=>'btn icon-trash'),
null,
__('Are you sure you want to delete # %s?',
$skill['Skill']['SkillID']
));
这篇关于CakePHP相当于html代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!