foodsoft/config/initializers/simple_form_bootstrap.rb

57 lines
2.1 KiB
Ruby
Raw Permalink Normal View History

# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
2014-11-21 14:37:56 +01:00
config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
2014-11-21 14:37:56 +01:00
b.wrapper tag: 'div', class: 'controls' do |ba|
ba.use :input
2014-11-21 14:37:56 +01:00
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
config.wrappers :prepend, tag: 'div', class: 'control-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
2014-11-21 14:37:56 +01:00
b.wrapper tag: 'div', class: 'controls' do |input|
input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
prepend.use :input
end
2014-11-21 14:37:56 +01:00
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
end
end
config.wrappers :append, tag: 'div', class: 'control-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
2014-11-21 14:37:56 +01:00
b.wrapper tag: 'div', class: 'controls' do |input|
input.wrapper tag: 'div', class: 'input-append' do |append|
append.use :input
end
2014-11-21 14:37:56 +01:00
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
end
end
2014-11-21 14:37:56 +01:00
2013-06-26 15:16:52 +02:00
# Do not use the label in tables
2014-11-21 14:37:56 +01:00
config.wrappers :intable, tag: 'div', class: 'control-group control-group-intable', error_class: 'error' do |b|
2013-06-26 15:16:52 +02:00
b.use :html5
b.use :placeholder
2014-11-21 14:37:56 +01:00
b.wrapper tag: 'div', class: 'controls controls-intable' do |ba|
2013-06-26 15:16:52 +02:00
ba.use :input
2014-11-21 14:37:56 +01:00
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
2013-06-26 15:16:52 +02:00
end
end
2014-11-21 14:37:56 +01:00
# Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
# Check the Bootstrap docs (http://twitter.github.com/bootstrap)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
config.default_wrapper = :bootstrap
end