css - Ruby on rails_format 带 Bootstrap 的表单字段

标签 css ruby-on-rails twitter-bootstrap ruby-on-rails-4.1

我想用 Boostrap CSS 格式化表单字段。

我在表单 View 文件中有以下代码:

<p>
  <%= f.label :country %>
  <%= f.select :country, ["India","USA","Australia"] %>
</p>

我希望它的格式为:

<select class="form-control">
    <option>India</option>
    <option>USA</option>
    <option>Australia</option>
</select>

我尝试了几种我认为可行的不同方法,但都没有成功。

最佳答案

<%= f.select :country, options_for_select(["India", "USA", "Australia"]), class: "form-control" %>

它将生成所需的输出。

关于css - Ruby on rails_format 带 Bootstrap 的表单字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30705925/

相关文章:

ruby-on-rails - rails : Bootstrap Editing Forms CSS

html - 使用 css 更改 html 标签的 href

ruby-on-rails - 如何在 Nginx 上使用 asset_path 和文件

html - Twitter Bootstrap 缩略图。使标题内嵌

ruby-on-rails - Capistrano 部署(cap 部署)失败,身份验证错误

ruby-on-rails - 使用 StrongParameters 允许无需删除其他键

javascript - 当此值更改时,如何确保 Bootstrap 列扩展以适应其内容的宽度?

html - 百分号代替常规标签

android - PWA - 为 Android 设备设置启动画面

javascript - 旋转文本保持宽度