Update the bootstrap generator to work with Bootstrap 3
See https://github.com/rafaelfranca/simple_form-bootstrap/pull/28
This commit is contained in:
parent
8bb1da36f0
commit
4963374e7b
|
@ -1,12 +1,11 @@
|
|||
===============================================================================
|
||||
|
||||
Be sure to have a copy of the Bootstrap stylesheet available on your
|
||||
application, you can get it on http://getbootstrap.com/2.3.2/.
|
||||
application, you can get it on http://getbootstrap.com/.
|
||||
|
||||
Inside your views, use the 'simple_form_for' with one of the Bootstrap form
|
||||
classes, '.form-horizontal', '.form-inline', '.form-search' or
|
||||
'.form-vertical', as the following:
|
||||
classes, '.form-horizontal' or '.form-inline', as the following:
|
||||
|
||||
= simple_form_for(@user, html: {class: 'form-horizontal' }) do |form|
|
||||
= simple_form_for(@user, html: { class: 'form-horizontal' }) do |form|
|
||||
|
||||
===============================================================================
|
||||
|
|
|
@ -1,48 +1,107 @@
|
|||
# Use this setup block to configure all options available in SimpleForm.
|
||||
SimpleForm.setup do |config|
|
||||
config.error_notification_class = 'alert alert-error'
|
||||
config.label_class = 'control-label'
|
||||
config.button_class = 'btn btn-default'
|
||||
config.boolean_label_class = nil
|
||||
|
||||
config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
|
||||
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
b.use :label
|
||||
b.wrapper tag: 'div', class: 'controls' do |ba|
|
||||
b.use :label, class: 'control-label'
|
||||
|
||||
b.wrapper tag: 'div' do |ba|
|
||||
ba.use :input, class: 'form-control'
|
||||
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
end
|
||||
|
||||
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
b.use :label, class: 'control-label'
|
||||
|
||||
b.wrapper tag: 'div' do |ba|
|
||||
ba.use :input
|
||||
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|
|
||||
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
b.use :label
|
||||
b.wrapper tag: 'div', class: 'controls' do |input|
|
||||
input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
|
||||
prepend.use :input
|
||||
end
|
||||
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
|
||||
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
|
||||
b.wrapper tag: 'div', class: 'checkbox' do |ba|
|
||||
ba.use :label_input
|
||||
end
|
||||
|
||||
b.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
|
||||
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
b.use :label_input
|
||||
b.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
|
||||
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
b.use :label, class: 'col-sm-3 control-label'
|
||||
|
||||
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
||||
ba.use :input, class: 'form-control'
|
||||
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
end
|
||||
|
||||
config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
|
||||
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
b.use :label
|
||||
b.wrapper tag: 'div', class: 'controls' do |input|
|
||||
input.wrapper tag: 'div', class: 'input-append' do |append|
|
||||
append.use :input
|
||||
b.use :label, class: 'col-sm-3 control-label'
|
||||
|
||||
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
||||
ba.use :input
|
||||
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
end
|
||||
|
||||
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
|
||||
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
|
||||
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
|
||||
ba.use :label_input, class: 'col-sm-9'
|
||||
end
|
||||
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
|
||||
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
|
||||
wr.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
end
|
||||
|
||||
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
||||
b.use :html5
|
||||
b.use :placeholder
|
||||
|
||||
b.use :label, class: 'col-sm-3 control-label'
|
||||
|
||||
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
||||
ba.use :input
|
||||
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
||||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
||||
end
|
||||
end
|
||||
|
||||
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
||||
# Check the Bootstrap docs (http://getbootstrap.com/2.3.2/)
|
||||
# Check the Bootstrap docs (http://getbootstrap.com)
|
||||
# to learn about the different styles for forms and inputs,
|
||||
# buttons and other elements.
|
||||
config.default_wrapper = :bootstrap
|
||||
config.default_wrapper = :vertical_form
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue