我正在使用 simple_form + bootstrap,但想知道是否可以使某些字段内联,而其他字段以相同的形式在标签下。
我什至可能想将一个表格分成两列或更多列。
有没有办法通过包装器或通过不同的表单构建器或样式来实现这一点?
谢谢!
最佳答案
我找到的解决方案包括使用 bootstrap 提供的“row”和“span”类,并使用简单表单提供的“wrapper_html”将它们插入到各个字段中。
例子:
.container
...
= simple_form_for(@stuff, :html => { :class => 'form-horizontal' }) do |f|
= f.error_notification
.form-inputs.row
= f.input :name, :wrapper_html => { :class => 'span6' }
= f.input :contact_name, :wrapper_html => { :class => 'span6' }
.form-inputs.row
= f.input :contact_email, :wrapper_html => { :class => 'span6' }
= f.input :contact_phone, :as => :string, :wrapper_html => { :class => 'span6' }
您可以阅读有关 Bootstrap 网格系统的文档:
http://twitter.github.com/bootstrap/scaffolding.html
或者查看一些 Bootstrap 和简单表单集成的示例:
http://simple-form-bootstrap.plataformatec.com.br/articles/new
希望有帮助!
关于ruby-on-rails-3 - 简单形式 Bootstrap 水平和内联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10466646/