<%= f.input :cat_id, :collection => @cats , :label => "分類" %>
但用這方法生成的select 的第一個選項會是空白
使用下列語法,可以把第一個空白選項取消
<%= f.input :cat_id, :collection => @cats ,:include_blank => false, :label => "分類" %>
或者可用 :prompt ,預設第一個選項的文字
<%= f.input :cat_id, :collection => @cats ,:include_blank => false,:prompt=>'請選一個分類' , :label => "分類" %>
沒有留言:
張貼留言