aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers
diff options
context:
space:
mode:
authorjpl2016-11-03 11:18:55 +0100
committerThomas Haddad2016-11-08 18:15:11 +0100
commit825152f5d74ab91c79adaadbd337585da4c82be8 (patch)
treee38c6f6ebc684ecfa259e9b88d6e3822889b4475 /config/initializers
parent7d32da0a6e2384eef088bc66b6fa08cda9d2b8ab (diff)
downloadchouette-core-825152f5d74ab91c79adaadbd337585da4c82be8.tar.bz2
fix simpleform inits dirty pimping
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/simple_form.rb18
-rw-r--r--config/initializers/simple_form_bootstrap.rb67
2 files changed, 36 insertions, 49 deletions
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
index d5492e529..472863fa8 100644
--- a/config/initializers/simple_form.rb
+++ b/config/initializers/simple_form.rb
@@ -5,8 +5,9 @@ SimpleForm.setup do |config|
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
- config.wrappers :default, class: :input,
- hint_class: :field_with_hint, error_class: :field_with_errors do |b|
+ config.wrappers :default, class: 'form-group',
+ error_class: 'has-error' do |b|
+ # hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
@@ -41,8 +42,8 @@ SimpleForm.setup do |config|
## Inputs
b.use :label_input
- b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
## full_messages_for
# If you want to display the full error message for the attribute, you can
@@ -72,7 +73,7 @@ SimpleForm.setup do |config|
config.error_notification_tag = :div
# CSS class to add for error notification helper.
- config.error_notification_class = 'error_notification'
+ config.error_notification_class = 'alert alert-error'
# ID to add for error notification helper.
# config.error_notification_id = nil
@@ -90,25 +91,24 @@ SimpleForm.setup do |config|
# config.collection_wrapper_class = nil
# You can wrap each item in a collection of radio/check boxes with a tag,
- # defaulting to :span. Please note that when using :boolean_style = :nested,
- # SimpleForm will force this option to be a label.
+ # defaulting to :span.
# config.item_wrapper_tag = :span
# You can define a class to use in all item wrappers. Defaulting to none.
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
- # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
+ config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
# You can define the class to use on all labels. Default is nil.
# config.label_class = nil
# You can define the default class to be used on forms. Can be overriden
# with `html: { :class }`. Defaulting to none.
- # config.default_form_class = nil
+ config.default_form_class = 'form'
# You can define which elements should obtain additional classes
- # config.generate_additional_classes_for = [:wrapper, :label, :input]
+ config.generate_additional_classes_for = [:label, :input]
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true
diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb
index 4f4dc23b3..be0f4bf55 100644
--- a/config/initializers/simple_form_bootstrap.rb
+++ b/config/initializers/simple_form_bootstrap.rb
@@ -14,8 +14,8 @@ SimpleForm.setup do |config|
b.use :label, class: 'control-label'
b.use :input, class: 'form-control'
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -26,8 +26,8 @@ SimpleForm.setup do |config|
b.use :label, class: 'control-label'
b.use :input
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -38,8 +38,8 @@ SimpleForm.setup do |config|
ba.use :label_input
end
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -47,8 +47,8 @@ SimpleForm.setup do |config|
b.optional :readonly
b.use :label, class: 'control-label'
b.use :input
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
@@ -62,8 +62,8 @@ SimpleForm.setup do |config|
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-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -76,8 +76,8 @@ SimpleForm.setup do |config|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -90,8 +90,8 @@ SimpleForm.setup do |config|
ba.use :label_input
end
- wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -103,8 +103,8 @@ SimpleForm.setup do |config|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
ba.use :input
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
end
@@ -118,45 +118,32 @@ SimpleForm.setup do |config|
b.use :label, class: 'sr-only'
b.use :input, class: 'form-control'
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
- config.wrappers :form_without_label, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
-
+ config.wrappers :multi_select, 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.wrapper tag: 'div', class: 'col-sm-12' do |ba|
+ b.use :label, class: 'control-label'
+ b.wrapper tag: 'div', class: 'form-inline' 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' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block small' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block small' }
end
- end
-
- config.wrappers :nested, :tag => 'span', :error_class => 'has-error' do |b|
- b.use :html5
- b.use :placeholder
- b.optional :readonly
- b.use :input
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
-
# Wrappers for forms and inputs using the Bootstrap toolkit.
# Check the Bootstrap docs (http://getbootstrap.com)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
- config.default_wrapper = :horizontal_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,
+ datetime: :multi_select,
+ date: :multi_select,
+ time: :multi_select
}
end
-