Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter-Bootstrap: Simple_form not making horizontal form or correct HTML output?

I don't know why Its not duplicating like the example. When I put the following code to have this form:

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form-horizontal" } ) do |f| %>
<%= f.input :user_name, :input_html => { :class => "span3" }, :hint => "just letters and numbers please." %>
<% end %>

Right now it looks like this:

enter image description here

When I want it to be like this (the first example here: http://simple-form-bootstrap.plataformatec.com.br/articles/new).

enter image description here

The Problem lies in the HTML being generated. My HTML is:

<div class="input string optional">
 <label for="user_user_name" class="string optional"> User name</label>
  <input type="text" size="50" name="user[user_name]" maxlength="25" id="user_user_name" class="string optional span3">
   <span class="hint">no spaces or special characters, just letters and numbers please</span>
</div>

And Simple_forms HTML:

<div class="control-group string required">
 <label for="article_name" class="string required">
  <abbr title="required">*</abbr> Name
 </label>
  <div class="controls">
   <input type="text" size="50" name="article[name]" id="article_name" class="string required span6">
    <p class="help-block">add your article title here</p>
  </div>
</div>

Totally different. I'm thinking the Bootstrap generator doesn't generate? What do you think? What should I do?

resources

https://github.com/plataformatec/simple_form

https://github.com/rafaelfranca/simple_form-bootstrap

http://simple-form-bootstrap.plataformatec.com.br/

like image 943
LearningRoR Avatar asked Feb 16 '12 12:02

LearningRoR


1 Answers

Have you added the initializer for simple_form? this initializer sets the wrappers that should be used to output the bootstrap html

rails generate simple_form:install --bootstrap

Note that this only works with simple_form 2!

like image 69
ahmeij Avatar answered Oct 14 '22 13:10

ahmeij