<%= simple_form_for [blog_post, comment], remote: true do |f| %>
<div class="row">
<%= f.input :content, label: false, input_html: { rows: 7 } %>
</div>
<% end %>
生成下一个代码:
<form>
<div class="row">
<div class="form-group text required blog_comment_content">
<div class="col-sm-9">
<textarea rows="7" class="text required form-control form-control" placeholder="Comments" name="blog_comment[content]" id="blog_comment_content"></textarea>
</div>
</div>
</div>
</form>
如何将包装'col-sm-9'移除或替换为'col-sm-12'?
答案 0 :(得分:2)
您可以在config/initializers/simple_form_bootstrap.rb
中设置包装器。
查看simple_form
的文档并查看example
。
答案 1 :(得分:1)
不是修改默认包装器,而是在simple_form设置块中添加custom包装器:customized_form
:
配置/初始化/ simple_form_bootstrap.rb
config.wrappers :customized_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :label, class: 'col-sm-12 control-label'
b.wrapper tag: 'div', class: 'col-sm-12' do |ba|
ba.use :input, class: 'form-control'
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
然后使用新创建的包装器:
simple_form_for([blog_post, comment], wrapper: :customized_form)