Instead of using the .form-actions class, which wraps the submit button in a gray block (which might not work for your page design), you can also wrap the button in the control group as follows:
<div class="control-group"> <div class="controls"> <%= f.button :submit %> </div> </div>
This is really only necessary if you use the .form-horizontal class in the form itself.
If you are looking for a replacement replacement creator that prints out bootstrap style markup for Rails, you can check out the gem I put together to handle these things:
https://github.com/potenza/bootstrap_form
Here you can customize the horizontal style form with the correct layout of the submit button:
<%= bootstrap_form_for(@user, html: { class: 'form-horizontal' }) do |f| %> <%= f.text_field :email %> <%= f.password_field :password %> <%= f.password_field :password_confirmation, label: 'Confirm Password' %> <%= f.control_group do %> <%= f.primary "Save User" %> <% end %> <% end %>
This is an example output:
<form accept-charset="UTF-8" action="/users" class="form-horizontal" id="new_user" method="post"> <div class="control-group"> <label class="control-label" for="user_email">Email</label> <div class="controls"> <input id="user_email" name="user[email]" size="30" type="text" /> </div> </div> <div class="control-group"> <label class="control-label" for="user_password">Password</label> <div class="controls"> <input id="user_password" name="user[password]" size="30" type="password" /> </div> </div> <div class="control-group"> <label class="control-label" for="user_password_confirmation">Confirm Password</label> <div class="controls"> <input id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password" /> </div> </div> <div class="control-group"> <div class="controls"> <input class="btn btn-primary" name="commit" type="submit" value="Save User" /> </div> </div> </form>
source share