I have inherited a βmulti-pageβ form along these lines, but it was created for Rails 2.2, and I'm just adapting the approach for Rails 3.
In fact, we used a tabbed layout with the whole form in one view - although this approach was heavily weighted against a single controller in Rails 2.2. I think it can be beaten better.
The layout meant that each section of the form could be accessed using tabs, but each section with tabs also had a link_to action for the next section, at the bottom of this section (for example, section A β B) that saved the entire form every time you clicked to a new section - I strongly edited the view only to give a view, but if it is a new form, it will show only each section after clicking the submit button for each section.
<ul id="tabs"> <li><a href="#SectionA">Section A</a></li> <li><a href="#SectionB">Section B</a></li> <li><a href="#SectionC">Section C</a></li> <li><a href="#SectionD">Section D</a></li> <li><a href="#SectionE">Section E</a></li> <li><a href="#SectionF">Section F</a></li> <li><a href="#SectionG">Section G</a></li> <li><a href="#SectionH">Section H</a></li> <li><a href="#SectionI">Section I</a></li> <li><a href="#SectionJ">Section J</a></li> </ul> <%=hidden_field_tag 'active_fabtabulous_tab'%> <% form_for(@detail) do |f| %> <%= f.error_messages %> <div class="panel" id="SectionA"> <b><u>Section A: Questionnaire Details</u></b> <br></br> <table> <tr> <td><div id="field_name">Questionnaire received on (dd/mm/yyyy):</div></td> <td><%= date_select("questionnaire", :received_on, :order=>[:day,:month,:year],:use_month_numbers=>true,:start_year=>Date.today.year,:end_year=>2008,:include_blank => true) %></td> </tr> <tr> <td><div id="field_name">Interviewer name:</div></td> <td><%=text_field("questionnaire",:intervieweename)%></td> </tr> </table> <%= f.submit "SectionB" , :class => "questButton" %> </div> <div class="panel" id="SectionB"> <b><u>Section B: Case Classification</u></b> <br></br> <% fields_for :patient, @patient do |p| %> <table> <tr> <td class="sectionA_is_this_case"><div id="field_name">Epidemiology definition:</div></td> <td><%= @patient.epidef %> </td> </tr> </table> <% end %> <table> <tr> <% fields_for :patient, @patient do |p| %> <td><div id="field_name">Asymptomatic:</div></td> <td><% if @patient.asymptomatic %>Yes<% else %>No<% end %></td> <% end %> <tr> <tr> <td><div id="field_name">Investigation is:</div></td> <td><%=select("detail", "invstatus", INVESTIGATION_IS)%></td> </tr> <tr> <td><div id="field_name">Outbreak keyword or number:</div></td> <td><%= f.text_field :outbreakid ,:cols => 40, :rows => 1 %></td> </tr> </table> </div> <%= f.submit "SectionC" , :class => "questButton" %> </div>
source share