Reputation: 558
I am building a one page flyer in rails 4. In that I need to edit multiple form in one single page. How can I achieve this?
I go through railscast 346 Wizard form but doesn't help me.
I need something as shown in image as I click on a "Done" information should save or updated.
Is it possible multiple submit button in one page with ajax/jquery.
Page can have multiple forms as shown in pic.
Upvotes: 0
Views: 522
Reputation: 44675
Of course you can. Assuming you have a partial _form.html.erb
containg sth in lines:
<%= form_for model, remote: true do |f| %>
<%# your form here %>
<%= f.submit %>
<% end %>
You can just take all the models you want to edit and iterate over them:
<% models_to_edit.each do |model|%>
<%= render 'form', model: model %>
<% end %>
Since each form has its own submit button, pressing it will submit only the form it belongs to.
Upvotes: 3