自定义简单表单集合_选择

时间:2016-08-17 00:44:35

标签: css ruby-on-rails simple-form

我有这个简单的表格,我希望能够用css设置下拉菜单的样式。

input_html: { class: "form-dropdown" }并没有改变风格。我如何才能正确地将一个类添加到简单形式collection_select中以在css中设置样式,或者是否有其他方式可以设置下拉菜单的样式?

这是我的简单形式:

<%= simple_form_for @document do |f| %>

    <%= f.collection_select :category_id, Category.all, :id, :name, {promt: "Choose a category" }, input_html: { class: "form-dropdown" } %>

    <%= f.input :title, label: "Title", label_html: { class: 'form-input' } %>

    <%= f.input :pdf, label: "Upload document:" %>

    <%= f.button :submit %>

<% end %>

2 个答案:

答案 0 :(得分:0)

请忘记 void ProcessRecords(SqlDataReader reader) { if (!reader.HasRows) { return; } using (reader) { while (reader.Read()) { var filePath = BuildFilePath(reader); var imageId = (int)reader["PhotoID"]; Task.Run(() => { ProcessRecord(imageId, filePath); }) .ContinueWith((task) => { Progress.Report("Processing " + Path.GetFileName(filePath)); }); } } } 这就是为什么它不起作用。像这样定义:

input_html:

<%= f.collection_select :category_id, Category.all, :id, :name, {promt: "Choose a category" }, { class: "form-dropdown" } %>

答案 1 :(得分:0)

<%= f.select :category_id, category_select_options, {prompt: "---Select Category---"}, required: :required, class: "form-control" %>

#
# In Appication Helper
#

def category_select_options
  Category.all.map{|c| [c.name,c.id] }
end