3
votes

1) How to build forms using simple form and twitter-bootstrap-rails so that they show cool bootstrap style validation errors?

2) How to build forms in twitter-bootstrap-rails so that they show cool bootstrap style validation errors?

3) I tried building form with simple_form. But validation is not showing any error messages. I am trying to add validation on User Model and Form generated by Devise

Techs: Rails 3.2.7.rc1, 1.9.2, twitter-ootstrap-rails 2.1.1, simple-form 2.0.2

code:

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

        <%= f.error_notification %>
    <%= f.input :fname, :placeholder=>"First name", :input_html => { :class => "enroll_input span4"} %>
    <%= f.input :lname, :placeholder=>"Last name", :input_html => { :class => "enroll_input span4"} %>
    <%= f.input :email,:placeholder=>"Email",:input_html => { :class => "enroll_input span4"}  %>
    <%= f.input :password, :placeholder=>"Password",:input_html => { :class => "enroll_input span4"} %>
    <div class="enroll_button"> <%= f.submit "  Enroll  ", :class=>"btn btn-primary pull-right btn-large" %></div>
        <% end %>

I am not sure though if this not working or jquery is not working.

3
Please show some code of what you have tried so far.Holger Just
Holger Just: update codeBhushan Lodha
Please, make sure you are using bootstrap as a default wrapper for this form. See config.default_wrapper = :bootstrap in config/initializers/simple_form.rb. To generate simple_form config with bootstrap wrapper use this command: rails generate simple_form:install --bootstrapmelekes
Checked everything is at its place..Bhushan Lodha

3 Answers

3
votes

try this:

<%= f.input :email do %>
   <%= f.input_field :email %>
<% end %>
1
votes

Here you can find notes about integration of the two, example app, the live app:

https://github.com/plataformatec/simple_form/#twitter-bootstrap