我尝试在html中重新创建这个菜单到cakephp表单,但我不知道如何将图标放在选项中...
<div class="ui fluid label dropdown">
<i class="dropdown icon"></i>
<span class="default text">Filter by</span>
<div class="menu">
<div class="item" data-value="0">With Comments<i class="comments right floated icon"></i></div>
<div class="item" data-value="1">Without Comments<i class="comments outline right floated icon"></i></div>
<div class="item" data-value="2">With Attachment<i class="attach right floated icon"></i></div>
<div class="item" data-value="3">Without Attachment</div>
</div>
</div>
这是我的CakePHP代码:
echo $this->Form->input('field',
array(
'options' => array('With Comments', 'Without Comments','Without Attachment'),
'empty' => 'Filter by',
'class' => 'ui dropdown',
'onchange' =>
'submitForm()',
'name' => 'FB'));
答案 0 :(得分:1)
您可能希望查看FormHelper documentation以验证您是否正确使用了帮助程序。
select输入类型允许一个名为'escape'的特殊$ option属性,它接受bool并确定是否对HTML实体进行编码select选项的内容。默认为true:
$options = [
'M' => 'Male <i class="fa fa-man"></i>',
'F' => 'Female <i class="fa fa-woman"></i>'
];
echo $this->Form->select('gender', $options, ['escape' => false]);
(改编自文档。)