simple_form with Foundation6.

52 views
Skip to first unread message

Hiroyuki Sato

unread,
Mar 9, 2016, 3:35:59 AM3/9/16
to SimpleForm

Hello members

  I would like to use simple_form with Foundation6.

Question 

  I referenced this page.

  * How to add class "is-invalid-input" to error '<input>' tag?
  * How to add class "is-invalid-label" to error '<label>' tag?

Environment

  * Rails: 4.2.5.2
  * foundation-rails: 6.1.2.0
  
My modification

  I changed simple_form_foundation.rb following.

  * change class name 'error' to 'form-error is-visible'
  * change error_notification_class class name 'alert-box alert' to 'alert callout'

  I'm not sure what is difference vertical_form, horizontal_form, ..
  But error message and error panel works as I expected.

Thank you for your advice.  

Diff  

diff --git a/config/initializers/simple_form_foundation.rb b/config/initializers/simple_form_foundation.rb
index 495ef35..e3f7184 100644
--- a/config/initializers/simple_form_foundation.rb
+++ b/config/initializers/simple_form_foundation.rb
@@ -15,7 +15,7 @@ SimpleForm.setup do |config|
     b.optional :min_max
     b.optional :readonly
     b.use :label_input
-    b.use :error, wrap_with: { tag: :small, class: :error }
+    b.use :error, wrap_with: { tag: :small, class: "form-error is-visible" }
 
     # b.use :hint,  wrap_with: { tag: :span, class: :hint }
   end
@@ -34,7 +34,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 :error, wrap_with: { tag: :small, class: "form-error is-visible" }
       # ba.use :hint,  wrap_with: { tag: :span, class: :hint }
     end
   end
@@ -49,7 +49,7 @@ SimpleForm.setup do |config|
         bb.use :label_text
       end
 
-      ba.use :error, wrap_with: { tag: :small, class: :error }
+      ba.use :error, wrap_with: { tag: :small, class: "form-error is-visible" }
       # ba.use :hint,  wrap_with: { tag: :span, class: :hint }
     end
   end
@@ -72,7 +72,7 @@ SimpleForm.setup do |config|
     b.use :label, class: 'hidden-for-small-up'
     b.use :input
 
-    b.use :error, wrap_with: { tag: :small, class: :error }
+    b.use :error, wrap_with: { tag: :small, class: "form-error is-visible" }
     # b.use :hint,  wrap_with: { tag: :span, class: :hint }
   end
 
@@ -87,7 +87,7 @@ SimpleForm.setup do |config|
       ba.use :label_input
     end
 
-    b.use :error, wrap_with: { tag: :small, class: :error }
+    b.use :error, wrap_with: { tag: :small, class: "form-error is-visible" }
     # b.use :hint,  wrap_with: { tag: :span, class: :hint }
   end
 
@@ -100,7 +100,7 @@ SimpleForm.setup do |config|
   config.item_wrapper_tag = :div
 
   # CSS class to add for error notification helper.
-  config.error_notification_class = 'alert-box alert'
+  config.error_notification_class = 'alert callout'
 
   # The default wrapper to be used by the FormBuilder.
   config.default_wrapper = :vertical_form

Reply all
Reply to author
Forward
0 new messages