我希望占位符字段说“单击以选择”,但默认占位符仍显示“选择某些选项”
<%= f.input :tag_ids, as: :select, collection: Tag.order(:name), label_method: :name, input_html: {multiple: true}, label: "Select Category:", placeholder: "Click to select", required: true %>
答案 0 :(得分:1)
您可以使用prompt
选项,查看简单表单的文档示例
f.input :age, collection: 18..60, prompt: "Select your age", selected: 21
https://github.com/plataformatec/simple_form#collections
您无需设置as: :select
,select
是呈现集合时的默认值。
答案 1 :(得分:0)
使用select的include_blank选项
select :object, :method, {:include_blank => ’-select-’}
有关更多信息,请参见the documentation