Starting a new Rails 4 : II. Forms with Simple_form bootstrap 3, rails 4, simple_form, helper

Some documentation

Setup

For Rails 4 you’ll need the prerelease, so gem i simple_form --pre, put it in gemfile and install it (with bootstrap structure) : rails g simple_form:install --bootstrap.

Usage

This is the new login form from the welcome page (look at the part I)

    = simple_form_for :sessions, :url => sessions_path, :html => {:class => 'well form-horizontal'} do |f|
      %div{:style => 'pading:30px;'}
        = button_close_modal
        %br
      .row{:style=>'margin:50px 0px;'}
        .col-span-4
          %h2 Login
        .col-span-4
          = f.error_notification
          = f.input :email
          = f.input :password
        .col-span-4
          = f.submit "Login", :class => 'btn btn-success btn-large'
    

As usual, later refactoring is need for semantic css …

The close button = button_close_modal is done this time with an helper method in application_helper.rb :

      def button_close_modal
        content_tag 'button', raw('×'), 'data-dismiss' => 'modal',
          'aria-hidden' => 'true', :style =>  "right:0px;", :type => 'button',
          :class => 'close'
      end
    

Further note when I’ll found something interesting ; but the documentation is up to date and every thing work well for the moment :)

Next step may be a date picker :)


comments powered by Disqus