Search code examples
ruby-on-rails-4simple-formsimple-form-for

simple_form inline on rails 4


I am using a simple_form and bootstrap in rails 4. I want the start date and start time to be on the same line and end date and end time on the same line. I have tried the solutions from similar problems but none of them are working. I am a newbie in rails. Please help me.

Here is my code:

        <%= b.input :start_date, wrapper: :horizontal_input_group do %>
        <%= b.input_field :start_date, class: "form-control date start" %>
        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
        <% end %>

        <%= b.input :start_time, wrapper: :horizontal_input_group do %>
        <%= b.input_field :start_time, as: :string, class: "form-control time start" %>
        <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
        <% end %>


        <%= b.input :end_date, wrapper: :horizontal_input_group do %>
        <%= b.input_field :end_date, class: "form-control date end" %>
        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
        <% end %>

        <%= b.input :end_time, wrapper: :horizontal_input_group do %>
        <%= b.input_field :end_time, as: :string, class: "form-control time end" %>
        <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>
        <% end %>

        <% end %>

Solution

  • getbootstrap.com/css/#grid this is what you should read. After wrapping your code with a <div class="container"></div> and inside that a <div class="row"></div> you can use the bootstrap columns to make your way and align everything perfectly.