I don't think there's a way to get exactly what you're looking for without redefining form_for. Or writing your own version of it.
You can get close with FormBuilders or Partials or Helpers, but none of these concepts either alone will let you do what you're looking to do.
A FormBuilder will let you define methods to be invoked on the form, like confirm and edit, but they would be part of the same form. Unless you create two forms.
In the related helper file:
class ExampleFormBuilder < ActionView::Helpers::FormBuilder
def confirm
hidden_field(:submission_state, :value => "confirmed") + "\n" + submit "Post"
end
def edit
hidden_field(:submission_state, :value => "edit_requested") + "\n" + submit "Edit"
end
end
Sample usage:
- form_for [@posts,@comments], :builder => ExampleFormBuilder do |f|
= f.confirm
- form_for [@posts,@comments], :builder => ExampleFormBuilder do |f|
= f.edit
When used with a partial you could do something like this
partial:
- form_for [@posts,@comments], :builder => ExampleFormBuilder do |f|
= f.send(action)
view:
= render :partial => :confirmation_for, :locals => {:action => :confirm}
= render :partial => :confirmation_for, :locals => {:action => :edit}
You could then bundle both partial calls into another partial. But that's going a little too far.