Update the simple_form initializers

This commit is contained in:
Petko Bordjukov 2015-04-20 16:22:36 +03:00
parent 8e406c7076
commit 97aeae12a3
2 changed files with 12 additions and 11 deletions

View File

@ -103,8 +103,9 @@ SimpleForm.setup do |config|
# You can define the class to use on all labels. Default is nil. # You can define the class to use on all labels. Default is nil.
# config.label_class = nil # config.label_class = nil
# You can define the class to use on all forms. Default is simple_form. # You can define the default class to be used on forms. Can be overriden
# config.form_class = :simple_form # with `html: { :class }`. Defaulting to none.
# config.default_form_class = nil
# You can define which elements should obtain additional classes # You can define which elements should obtain additional classes
# config.generate_additional_classes_for = [:wrapper, :label, :input] # config.generate_additional_classes_for = [:wrapper, :label, :input]

View File

@ -45,7 +45,8 @@ SimpleForm.setup do |config|
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5 b.use :html5
b.optional :readonly b.optional :readonly
b.use :label_input b.use :label, class: 'control-label'
b.use :input
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end end
@ -107,13 +108,6 @@ SimpleForm.setup do |config|
end end
end end
config.wrappers :horizontal_submit, tag: 'div', class: 'form-group' do |b|
b.optional :readonly
b.wrapper tag: 'div', class: 'col-sm-offset-2 col-sm-10' do |ba|
ba.use :input
end
end
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5 b.use :html5
b.use :placeholder b.use :placeholder
@ -132,5 +126,11 @@ SimpleForm.setup do |config|
# Check the Bootstrap docs (http://getbootstrap.com) # Check the Bootstrap docs (http://getbootstrap.com)
# to learn about the different styles for forms and inputs, # to learn about the different styles for forms and inputs,
# buttons and other elements. # buttons and other elements.
# config.default_wrapper = :vertical_form config.default_wrapper = :vertical_form
config.wrapper_mappings = {
check_boxes: :vertical_radio_and_checkboxes,
radio_buttons: :vertical_radio_and_checkboxes,
file: :vertical_file_input,
boolean: :vertical_boolean,
}
end end