Form_for inputs and submit button in different partials

ruby-on-rails-3

Solution

You can do that as follows:

# _post_form.html.erb
<%= form_for(@post) do |f| %>
 <% @form = f%>
 <%= render 'form_fields'%>
 <%= render 'form_actions'%>
<% end %>

# _form_fields.html.erb
<div class="field">
 <%= @form.label :name %><br />
 <%= @form.text_field :name %>
</div>
<div class="field">
 <%= @form.label :title %><br />
 <%= @form.text_field :title %>
</div>
<div class="field">
 <%= @form.label :content %><br />
 <%= @form.text_area :content %>
</div>

# _form_actions.html.erb
<div class="actions">
  <%= @form.submit %>
</div>

Problem

Is there a way to split an a form (using form_for) across two partials? I want to have text boxes in one partial, and my submit button in another.

Original source