1
votes

I want to display a form with the bootstrap classes (see https://github.com/plataformatec/simple_form#twitter-bootstrap)

I installed simple form with bootstrap argument:

rails generate simple_form:install --bootstrap

In my form:

<%= simple_form_for(resource,
                    :as => resource_name,
                    :url => registration_path(resource_name),
                    :html => {:class => 'form-horizontal'}) do |f| %>
    <%= devise_error_messages! %>

    <%= f.label :email %>
    <%= f.email_field :email %>
    ...

And the generated HTML looks like this:

<label class="email optional control-label" for="user_email">Email</label>
<input id="user_email" name="user[email]" size="30" type="email" value="">

(No wrapper tags).

Why the wrapper tags are not applied ?


What I tried:

Uninstalling and reinstalling the gem:

bundle update; bundle install; bundle;
rails d simple_form:install
rails generate simple_form:install --bootstrap

I checked that the simple_form_bootstrap.rb config file is called when the server starts; and it is.

I tried to force the wrapper to bootstrap in the form (still no wrapper tags):

<%= simple_form_for(resource,
                    :as => resource_name,
                    wrapper: :bootstrap,
                    ...
1

1 Answers

2
votes

f.label and f.email_field do not use wrappers. f.input does.

By replacing

<%= f.label :email %>
<%= f.email_field :email %>

with

<%= f.input :email %>

wrappers are applied.