Skip to content

Zurb's Foundation integration

Ian Vaughan edited this page May 16, 2014 · 2 revisions

Zurb's Foundation integration

Simple Form 1.5

How

Instructions for (probably half-baked) Foundation integration (SimpleForm 1.5):

  1. Edit config/initializers/simple_form.rb at line 59:
# You can define the class to use on all forms. Default is simple_form.
# config.form_class = :simple_form

Define config.form_class with the following :

config.form_class = :nice
  1. Create the following :
# lib/core_ext/simple_form/inputs/string_input.rb
SimpleForm::Inputs::StringInput.class_eval do
  alias :old_input_html_classes :input_html_classes
  def input_html_classes
    super + [:"input-text"]
  end
end
  1. Create the following
# lib/core_ext/simple_form/inputs/password_input.rb
SimpleForm::Inputs::PasswordInput.class_eval do
  alias :old_input_html_classes :input_html_classes
  def input_html_classes
    super + [:"input-text"]
  end
end
  1. Make sure your two core_ext files are properly included in your application, either by adding lib/core_ext to the load_path, or by including them manually.
  • Putting the files in autoload_path in config/application.rb does not work as it tries to load the extensions to the class before the class has been loaded.
  • Adding the following lines at the end of the config/initializers/simple_form.rb workeds:
    • require Rails.root.join("lib/core_ext/simple_form/inputs/string_input")
    • require Rails.root.join("lib/core_ext/simple_form/inputs/password_input")
  • Adding the following line at the end of the above file, will load every customization for simple_form: Dir[Rails.root.join("lib/core_ext/simple_form/**/*.rb")].each { |f| require f }