html - How to render partial form as a horizontal form in rails 4 -
i have partial (triggered ajax) on main page consists of form. form displayed horizontally rather vertically. have tried such wrapping in <form class="form-inline">
i've tried <%=f.number_field :pointsspend, :class => "checkbox inline"%>
, altering css display: inline
none of seems work
the main form in partial rendered:
<div class="row"> <div class="col-md-12"> <%= link_to image_tag("biceps.jpg"),'#', id: 'challengebutton', class: "btn btn-lg btn-primary" %> <div id="challengecentre"></div> </div> </div>
the form
<%= form_for(@challenge) |f| %> <% if @challenge.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@challenge.errors.count, "error") %> prohibited challenge being saved:</h2> <ul> <% @challenge.errors.full_messages.each |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :pointsspend %><br> <%= f.number_field :pointsspend %> </div> <div class="field"> <%= f.label :rules %><br> <%= f.text_area :rules %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> </form>
you should able pass class form_for
method this:
<%= form_for(@challenge, html: { class: 'form-inline' }) |f| %> <% if @challenge.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@challenge.errors.count, "error") %> prohibited challenge being saved:</h2> <ul> <% @challenge.errors.full_messages.each |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :pointsspend %><br> <%= f.number_field :pointsspend %> </div> <div class="field"> <%= f.label :rules %><br> <%= f.text_area :rules %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> </form>
Comments
Post a Comment