我正在尝试以简单形式为select字段添加CSS,但未应用。我尝试了以下方式,
pycharm --community(2019.1)
我找到了类似的答案,但无法弄清楚。这是链接Adding a css class to select in Rails。
答案 0 :(得分:1)
如果您使用的是simple_form
,则应使用其as: :select
表示法
= f.input :user_types, as: :select,
collection: [['Type', ''], ['College', 'admin'], ['Student', 'student']],
input_html: { id: 'college_admin_type', class: 'form-control custom-drop-icon' }
但是,如果您使用的是默认的select
帮助器,则应将html选项作为第二个选项的哈希值传递。
= f.select(:user_types, [['Type', ''], ['College', 'admin'], ['Student', 'student']], {}, { class: 'form-control custom-drop-icon' })