【问题标题】:Rails f.select does not style with bootstrap classRails f.select 没有引导类的样式
【发布时间】:2016-06-08 19:53:58
【问题描述】:

我有一个选择字段,用于选择日期(年份)

  <%= f.select :finishdate, (Time.zone.now.year - 30)..(Time.zone.now.year) + 5, {class: "form-control"} %>

但即使我使用引导样式,我也不会自行设置样式。它不是使用引导程序设置选择的样式,而是不使用样式。

【问题讨论】:

  • 你能显示正在生成的 html 吗?我相信select 方法需要选项,然后是 html 选项。 select(object, method, choices = nil, options = {}, html_options = {}, &amp;block)

标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4 twitter-bootstrap-3


【解决方案1】:

试试这个:

 <%= f.select :finishdate, (Time.zone.now.year - 30)..(Time.zone.now.year) + 5, {}, class: "form-control" %>

See here 用于方法 select

您需要按照 select 方法的语法样式传递您的 html 选项(例如 class: " ") 不带 {}

【讨论】:

  • @GurmukhSingh 好的,我已经更新了我的答案,希望对您有所帮助!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-15
相关资源
最近更新 更多