function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Multipage Form

Im working on a form where data is put in for an order. The data inputs are split into 5 separate pageBlockSections. How can I take each one of my pageBlockSections and make it a separate page. I want a next button down bottom but dont know how to override the save button and make it go to the next page. Heres the code:

<apex:page sidebar="false" standardController="lead"   showHeader="false" extensions="GLeadExtension"> 
<apex:composition template="{!$Site.Template}">
<apex:define name="body">
<h1>Conveyor Application Request</h1>
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
<apex:pageBlockSection title="Company Detail" columns="2">
<apex:inputField value="{!}"/>
<apex:inputField value="{!}"/>
<apex:inputField value="{!Lead.firstname}"/>
<apex:inputField value="{!Lead.lastname}"/>
<apex:inputField value="{!Lead.title}"/>

<apex:inputField value="{!}"/>
<apex:inputField value="{!Lead.street}"/>
<apex:inputField value="{!}"/>
<apex:inputField value="{!Lead.state}"/>
<apex:inputField value="{!Lead.postalcode}"/>
<apex:inputField value="{!}"/>
<apex:inputField value="{!}"/>
<apex:inputField value="{!Lead.fax}"/>
<apex:inputField value="{!Lead.status}"/>

<apex:pageBlockSection title="Product Conveyed - Additional Information" columns="2">

<apex:inputField value="{!Lead.Product_conveyed__c}"/>
<apex:inputField value="{!Lead.Chemical_formula__c}"/>
<apex:inputField value="{!Lead.Bulk_density_kg_dm3__c}"/>
<apex:inputField value="{!Lead.Particle_size_max_m__c}"/>
<apex:inputField value="{!Lead.Particle_size_min_m__c}"/>
<apex:inputField value="{!Lead.Majority_between_start__c}"/>
<apex:inputField value="{!Lead.end_m__c}"/>
<apex:inputField value="{!Lead.Is_the_product_abrasive__c}"/>
<apex:inputField value="{!Lead.Flowability__c}"/>

<apex:inputField value="{!Lead.The_product_is__c}"/>
<apex:inputField value="{!Lead.Aggressive_in_other_ways_additional_info__c}"/>
<apex:inputField value="{!Lead.Angle_of_repose__c}"/>
<apex:inputField value="{!Lead.Other_product_properties__c}"/>

<apex:pageBlockSection title="Installation - Additional Information" columns="2">
<apex:inputField value="{!Lead.Capacity_ton_h__c}"/>
<apex:inputField value="{!Lead.Other_intervals__c}"/>
<apex:inputField value="{!Lead.Total_conveying_distance_m__c}"/>
<apex:inputField value="{!Lead.Horizontal_m__c}"/>
<apex:inputField value="{!Lead.Vertical_m__c}"/>
<apex:inputField value="{!Lead.Number_of_bends__c}"/>
<apex:inputField value="{!Lead.Type_of_pipe_system__c}"/>
<apex:inputField value="{!Lead.Diameter__c}"/>
<apex:inputField value="{!Lead.Humidity_of_the_product__c}"/>
<apex:inputField value="{!Lead.Hygroscopic_moisture__c}"/>
<apex:inputField value="{!Lead.Product_picked_up_from__c}"/>
<apex:inputField value="{!Lead.If_Others__c}"/>
<apex:inputField value="{!Lead.The_installation_is__c}"/>
<apex:inputField value="{!Lead.The_operation_is__c}"/>
<apex:inputField value="{!Lead.Other_information__c}"/>
Best Answer chosen by Admin (Salesforce Developers) 

Look at the sample code for the Opportunity Wizard


it does basically what you are describing, linking multiple pages in one controller.


and you put your save button on the last page.

All Answers


Look at the sample code for the Opportunity Wizard


it does basically what you are describing, linking multiple pages in one controller.


and you put your save button on the last page.

This was selected as the best answer

This is exactly what I was looking for earlier but do I need to make a new controller for the code in order to make the wizard or is there a way i can just transfer my code to make this work?


As long as each page uses the same controller, you should be able to use the existing one.

Just make sure you setredirect(false) on your next button so you don't reinitialize the controller.


Good Luck!

Paul OveryPaul Overy

Jim referenced the perfect example.


To change your pages, you'll need to break up everything into 5 separate pages, then create a function for each page that'll look something like this:


public PageReference pg1() { return Page.myPage1; } public PageReference pg2() { return Page.myPage2; } public PageReference pg3() { return Page.myPage3; } public PageReference pg4() { return Page.myPage4; } public PageReference pg5() { return Page.myPage5; }

 The buttons on each page will need to call the correct function and the myPage# portion will need to match the actual VisualForce page names.


You'll also need some sort of "Save" button/function.


As Jim said, make sure you use the same controller for all 5 pages and you should be fine.





Look at "The Opportunity Wizard Controller " chapter.


This will give you exact idea.





Thanks everyone. Works perfectly!