cakephp:我想要一个带有选项但没有 optgroup 的简单选择框
cupcake 论坛插件中 forum_categories 的选择框不允许我选择其选项。当我用鼠标悬停选项时,突出显示仍停留在“选择论坛”处。以下是原文
<?php
echo $form->input('forum_category_id', array(
'options' => $forums,
'empty' => '-- '. __d('forum', 'Select a Forum', true) .' --',
'label' => __d('forum', 'Forum Category', true)
));
?>
,我将其修改为:
<?php
echo $form->input('Topic.forum_category_id',array(
'empty' => 'Select a Forum',
'options' => $forums
));
?>
以下是它生成的html代码:
<select name="data[Topic][forum_category_id]" id="TopicForumCategoryId">
<option value="">Select a Forum</option>
<optgroup label="Summer Camp">
</optgroup>
</select>
在forumcategory模型中查找stmt:
$forums = $this->Forum->find('list', array(
'conditions' => array(
'Forum.status' => 0,
'Forum.accessView <=' => $access,
'Forum.access_level_id' => $accessLevels
),
'order' => 'Forum.orderNo ASC'
));
如何摆脱上面html代码中的optgroup?我只想要一个带有选项的简单选择框,没有如下所示的 optgroup:
<select name="data[Topic][forum_category_id]" id="TopicForumCategoryId">
<option value="">Select a Forum</option>
<option value="1">Summer Camp</option>
</select>
谢谢。
The select box for forum_categories in the cupcake forum plugin doesn't allow me to select its options. When I rollover the options with my mouse, the highlight stays at 'Select a Forum'. The following is the original
<?php
echo $form->input('forum_category_id', array(
'options' => $forums,
'empty' => '-- '. __d('forum', 'Select a Forum', true) .' --',
'label' => __d('forum', 'Forum Category', true)
));
?>
And i modified it to:
<?php
echo $form->input('Topic.forum_category_id',array(
'empty' => 'Select a Forum',
'options' => $forums
));
?>
The following is the html code it is generating:
<select name="data[Topic][forum_category_id]" id="TopicForumCategoryId">
<option value="">Select a Forum</option>
<optgroup label="Summer Camp">
</optgroup>
</select>
The find stmt in the forumcategory model:
$forums = $this->Forum->find('list', array(
'conditions' => array(
'Forum.status' => 0,
'Forum.accessView <=' => $access,
'Forum.access_level_id' => $accessLevels
),
'order' => 'Forum.orderNo ASC'
));
How can I get rid of the optgroup in the html code above? I just want a simple select box with options and no optgroup like the following:
<select name="data[Topic][forum_category_id]" id="TopicForumCategoryId">
<option value="">Select a Forum</option>
<option value="1">Summer Camp</option>
</select>
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能有点晚了但是
当你得到选择组时
您的选项如下所示:
probably a bit late but
you get opt groups when
your options looks like this :
尝试:
Try: