cakephp:我想要一个带有选项但没有 optgroup 的简单选择框

发布于 2024-12-24 22:44:32 字数 1415 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纸伞微斜 2024-12-31 22:44:32

可能有点晚了但是
当你得到选择组时
您的选项如下所示:

$arr = array(
    'optgroup' => array(
        '1','2','3'),
     'optgroup2' => array(
         '1',2,3)
);                              
echo $this->Form->input('some',array('options' => $arr));

probably a bit late but
you get opt groups when
your options looks like this :

$arr = array(
    'optgroup' => array(
        '1','2','3'),
     'optgroup2' => array(
         '1',2,3)
);                              
echo $this->Form->input('some',array('options' => $arr));
呆° 2024-12-31 22:44:32

尝试:


echo $this->Form->input('Topic.forum_category_id', array('options' => $forums, 'empty' => 'Select a Forum'));

Try:


echo $this->Form->input('Topic.forum_category_id', array('options' => $forums, 'empty' => 'Select a Forum'));

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文