From 8e7ba80e2955acfac09bfd66575b82876a6c2fb3 Mon Sep 17 00:00:00 2001 From: Dimitri Jorge Date: Thu, 31 Jul 2014 19:36:59 +0200 Subject: [PATCH] Improve foundation initializer code quality and comment to make it clearer --- .../initializers/simple_form_foundation.rb | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb b/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb index 4b3f68cb..495ef355 100644 --- a/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +++ b/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb @@ -1,9 +1,13 @@ # Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| - # Don't forget to edit this file to adapt to your needs (specially + # Don't forget to edit this file to adapt it to your needs (specially # all the grid-related classes) + # + # Please note that hints are commented out by default since Foundation + # does't provide styles for hints. You will need to provide your own CSS styles for hints. + # Uncomment them to enable hints. - config.wrappers :vertical_foundation, class: :input, hint_class: :field_with_hint, error_class: :error do |b| + config.wrappers :vertical_form, class: :input, hint_class: :field_with_hint, error_class: :error do |b| b.use :html5 b.use :placeholder b.optional :maxlength @@ -13,8 +17,6 @@ SimpleForm.setup do |config| b.use :label_input b.use :error, wrap_with: { tag: :small, class: :error } - # Uncomment the following line to enable hints. The line is commented out by default since Foundation - # does't provide styles for hints. You will need to provide your own CSS styles for hints. # b.use :hint, wrap_with: { tag: :span, class: :hint } end @@ -33,7 +35,7 @@ SimpleForm.setup do |config| b.wrapper :right_input_wrapper, tag: :div, class: 'small-9 columns' do |ba| ba.use :input ba.use :error, wrap_with: { tag: :small, class: :error } - ba.use :hint, wrap_with: { tag: :span, class: :hint } + # ba.use :hint, wrap_with: { tag: :span, class: :hint } end end @@ -52,6 +54,13 @@ SimpleForm.setup do |config| end end + # Foundation does not provide a way to handle inline forms + # This wrapper can be used to create an inline form + # by hiding that labels on every screen sizes ('hidden-for-small-up'). + # + # Note that you need to adapt this wrapper to your needs. If you need a 4 + # columns form then change the wrapper class to 'small-3', if you need + # only two use 'small-6' and so on. config.wrappers :inline_form, tag: 'div', class: 'column small-4', hint_class: :field_with_hint, error_class: :error do |b| b.use :html5 b.use :placeholder @@ -67,10 +76,10 @@ SimpleForm.setup do |config| # b.use :hint, wrap_with: { tag: :span, class: :hint } end - # Example of use: + # Examples of use: # - wrapper_html: {class: 'row'}, custom_wrapper_html: {class: 'column small-12'} # - custom_wrapper_html: {class: 'column small-3 end'} - config.wrappers :foundation_customizable_wrapper, tag: 'div', error_class: :error do |b| + config.wrappers :customizable_wrapper, tag: 'div', error_class: :error do |b| b.use :html5 b.optional :readonly @@ -94,5 +103,5 @@ SimpleForm.setup do |config| config.error_notification_class = 'alert-box alert' # The default wrapper to be used by the FormBuilder. - config.default_wrapper = :vertical_foundation + config.default_wrapper = :vertical_form end