1
votes

I have been using simple_form for a few years now, but always either by itself or with Bootstrap. I'm using Foundation in a new project, and I have followed Zurb's instructions for installing the foundation-rails gem. I have also run:

rails g simple_form:install --foundation

And it has created the requisite files.

Now for the confusing part. When I used to generate a controller or a scaffold with simple_form for Bootstrap, it would make the form look great by default.

But when I run those same generators in my new Rails project using simple_form for Foundation, the forms don't appear to be styled at all. The fields stretch all the way across the screen.

Passing in the wrapper HTML classes that are specified in the config/initializers/simple_form_foundation.rb file don't do anything.

For example:

<%= simple_form_for(@organization, html: { class: "horizontal-form" }) do |f| %>

I can see in the HTML source that it is indeed putting "inline-form" as a class on the form, but there's nothing else going on. None of the wrapper stuff around any of the divs is different, it's just plain:

<div class="input string optional organization_official_name">
    <label class="string optional" for="organization_official_name">Official Name</label>
    <input class="string optional" id="organization_official_name" name="organization[official_name]" type="text" value="Voolith">
</div>

I have not done anything fancy in my application layout yet, other than the nav bar which is using Zurb classes and works perfectly.

I think I am confused on what exactly simple_form is supposed to do here? I don't understand the connection between the configuration in the simple_form.rb and simple_form_foundation.rb files and CSS classes.

Right now, passing the "vertical-form" or "horizontal-form" classes as I have done above doesn't do anything. Isn't simple_form somehow supposed to read that value and render the form differently?

1

1 Answers

3
votes

I had this same problem and googling didn't yield quick answers.

I believe instead of

<%= simple_form_for(@organization, html: { class: "horizontal-form" }) do |f| %>

try

<%= simple_form_for(@organization, :wrapper => :horizontal_form) do |f| %>

This references the config.wrappers in config/initializers/simple_form_foundation.rb