如何将glyphicon放入cakephp提交表单中?

时间:2022-10-20 15:43:24

The code:

<?php echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>', array('class' => array('btn btn-danger')), array('escape' => false)); ?>

Instead of glyphicon it shows just text:

而不是glyphicon它只显示文字:

<i class="glyphicon glyphicon-arrow-right"></i>

How to solve this?

怎么解决这个?

2 个解决方案

#1


As per the docs, you can't use escape with Submit- you have to use Button instead and specify that it's a submit button:

根据文档,你不能使用提交转义 - 你必须使用Button而是指定它是一个提交按钮:

echo $this->Form->button('<i class="glyphicon glyphicon-arrow-right"></i>', array(
    'type' => 'submit', 
    'class' => 'btn btn-danger', 
    'escape' => false
));

#2


Form->submit() should take two options, a caption and an array of options. You are passing it the caption plus two arrays. Also I don't think in this case you need to wrap these options within sub-arrays.

Form-> submit()应该有两个选项,一个标题和一组选项。你传递标题加上两个数组。另外我不认为在这种情况下你需要在子数组中包装这些选项。

Try this:

echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>',
     array('class' => 'btn btn-danger', 'escape' => false)
);

#1


As per the docs, you can't use escape with Submit- you have to use Button instead and specify that it's a submit button:

根据文档,你不能使用提交转义 - 你必须使用Button而是指定它是一个提交按钮:

echo $this->Form->button('<i class="glyphicon glyphicon-arrow-right"></i>', array(
    'type' => 'submit', 
    'class' => 'btn btn-danger', 
    'escape' => false
));

#2


Form->submit() should take two options, a caption and an array of options. You are passing it the caption plus two arrays. Also I don't think in this case you need to wrap these options within sub-arrays.

Form-> submit()应该有两个选项,一个标题和一组选项。你传递标题加上两个数组。另外我不认为在这种情况下你需要在子数组中包装这些选项。

Try this:

echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>',
     array('class' => 'btn btn-danger', 'escape' => false)
);