新手问题 form_for 下面的 select 怎么定义 class 属性?

lehug · March 12, 2016 · Last by lehug replied at October 30, 2017 · 2430 hits

form_for 下面有一个 select 多选框,<%=f.select(:page,options_for_select([['首页','sy']]))%>,求教这个里面如何添加 class 属性? 源码是这样的,有些看不懂 def select(method, choices = nil, options = {}, html_options = {}, &block) @template.select(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options), &block) end 麻烦大神给个示范,谢谢

<%=f.select(:page,options_for_select([['首页','sy']]),{},{:class =>"form-control"}) %> 这样解决了

lehug closed this topic. 30 Oct 08:20
lehug reopened this topic. 30 Oct 08:21

回过来看,这个问题很小白,谢谢解答~

lehug closed this topic. 30 Oct 08:22
You need to Sign in before reply, if you don't have an account, please Sign up first.