我必須使用simple_form插件這種形式:如何讓下拉菜單中的每個選項與關聯simple_form調用相關聯?
<%= simple_form_for([@video, @video.comments.new], :remote => true) do |f| %>
<%= f.association :comment_title, :collection => @video.comment_titles, :label => "Comment Title:", :include_blank => false %>
<%= f.input :body, :label => false, :placeholder => "Post a comment." %>
<%= f.button :submit, :value => "Post" %>
<% end %>
,這將創建一個下拉列表與這條線:
<%= f.association :comment_title, :collection => @video.comment_titles, :label => "Comment Title:", :include_blank => false %>
我的問題是你如何修改這個代碼,以便每次下拉項目是鏈接到每個comment_title
的個人秀節目?
UPDATE
下面是從代碼從第一個答案生成的HTML:
<select class="select optional" id="comment_comment_title_id" name="comment[comment_title_id]">
<option value="<a href=" comment_titles="" 224"="">#<CommentTitle:0x10353b890>">#<CommentTitle:0x10353b890></option>
<option value="<a href=" comment_titles="" 225"="">#<CommentTitle:0x1035296e0>">#<CommentTitle:0x1035296e0></option>
<option value="<a href=" comment_titles="" 226"="">#<CommentTitle:0x1035295a0>">#<CommentTitle:0x1035295a0></option>
</select>
哦,不知道這甚至可能...我打算使用JavaScript,但這是更清潔...我會試試這 – 2011-04-20 05:04:51
一個問題,雖然......爲什麼有'CT'在第一鏈接之前的數組元素? – 2011-04-20 05:06:19
好吧,第一個元素是suppossed是一個選項值: – 2011-04-20 05:21:39