[英]Using form_for multi-select fields with acts_as_taggable_on
我無法找出使用多選字段的預定選項集的正確代碼。 我希望在用戶可以選擇的下拉列表中列出技能列表。 這是我正在使用的代碼,它可以作為單個選擇字段正常工作,但不能作為多選:
<%= form_for(@user, :html => { :class => "form-stacked" } ) do |f| %>
...
<div class="clearfix"><%= f.select :skill_list, options_for_select(["Asst", "dir", "pres"]),
{
:multiple => true,
:class => "chzn-select",
:style => "width:450px;" } %></div>
...
<% end %>
有人有什么建議嗎? 最終,我想在其他地方存儲多選表單的所有選項,因為會有一堆,但這是我無法弄清楚的第一個挑戰..
謝謝。
編輯
我也嘗試過:
:html => { :multiple => true, :class => "chzn-select", :style => "width:450px;" } and it doesnt work either
需要有兩對括號,一個用於options
,一個用於html_options
,如下所示:
<%= f.select :skills_list, options_for_select(["Asst", "dir", "pres"]), {}, {:multiple => true, :class => "chzn-select", :style => "width:450px;" } %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.