Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Form in Bootstrap Modal

I'm trying to put a rails form in a bootstrap modal dialog. I'd like to use the modal-footer to hold the cancel/submit buttons, but this doesn't seem to work inside the form tag.

<div class="modal-body">
  <%= simple_form_for [@state, @search] do |f| %>
     <!-- long form here -->
     <div class="modal-footer">
       <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
       <%= f.button :submit, :class => 'btn btn-primary' %>
     </div>
  <% end %>
</div>
like image 326
Mark Avatar asked Oct 29 '12 12:10

Mark


1 Answers

That's because you are putting the footer inside the body. Use this way instead:

<%= simple_form_for [@state, @search] do |f| %>
  <div class="modal-body">
    <!-- long form here -->
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
    <%= f.button :submit, :class => 'btn btn-primary' %>
  </div>
<% end %>
like image 125
MurifoX Avatar answered Sep 28 '22 11:09

MurifoX