在表单中使用select_tag时的URL参数

时间:2011-04-07 23:08:02

标签: ruby-on-rails

我有一个表格,我使用options_from_collection_for_select。

该属性称为类别,并具有关联的ID。我很乐意在URL中看到params:& category = 32

但是,他们现在看起来像& category = 32,附加& multiselect_select_category = 32

我得到的完整网址是:

<url>/advanced_search_res?utf8=%E2%9C%93&name=test&category=29&category=32&category=34&category=35&multiselect_select_category=29&multiselect_select_category=32&multiselect_select_category=34&multiselect_select_category=35

表单内的电话是:     &lt;%= select_tag“category”,options_from_collection_for_select(@category,“id”,“name”),: multiple =&gt; true,:class =&gt;“bbFormSelect”,:id =&gt;“select_category”,:name =&gt; “category”%&gt;

有关如何做到这一点的任何想法?谢谢!

===============

更新:select标签的html如何显示

<select class="bbFormSelect" id="select_category" multiple="multiple" name="category[]" style="display: none; ">
<option value="1">Aerospace &amp; Defense</option>
<option value="25">Leisure</option>
<option value="29">Nonprofit Institutions</option>
<option value="32">Retail</option>
...
<button type="button" class="ui-multiselect ui-widget ui-state-default ui-corner-all" title="" aria-haspopup="true" style="width: 225px; "><span class="ui-icon ui-icon-triangle-2-n-s"></span><span>1 selected</span></button>

1 个答案:

答案 0 :(得分:0)

我注意到的第一件事是,当select_tag的语法是:

时,你明确地将name属性作为html属性提供
select_tag(name, option_tags = nil, options = {})

名称由第一个参数设置,因此它已设置为“category”。

你能提供表格中由rails生成的html源吗?