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
Sophia GSophia G 

How to add Visualforce page to controller?

Hi,
I have 2 Visualforce pages that I would like to share the 1 controller. The first page which is already connected to the controller is a list, and the second page is a registration form. How would I add the registration form to the controller?
Thank you

Page 1:
<apex:page controller="NFOSController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accs}" var="a">
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Availability__c}"/>
                <apex:column value="{!a.Number_of_Competitors__c}"/>
                <apex:column value="{!a.Active__c}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class NFOSController {

    public List<Division_Space2__c> accs {
        get {
            if (accs == null) accs = [select name, Availability__c, Number_of_Competitors__c, Active__c from Division_Space2__c limit 1000];
            return accs;
        }
        set;
    }
}
​​​​​​​
Page 2:
<apex:page standardController="Competitor2__c" lightningStylesheets="true">
<apex:sectionHeader title="Noosa Festival of Surfing" />
       <apex:form id="NFOS1"> 
        
    <apex:pageBlock title="New Competitor" mode="edit">
             <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
             </apex:pageBlockButtons>
                        
            <apex:pageBlockSection columns="2" showHeader="true" title="Registration" >
                <apex:inputField value="{!Competitor2__c.Name}" required="false"/>
                <apex:inputField value="{!Competitor2__c.First_Name__c}" required="false"/>
                <apex:inputField value="{!Competitor2__c.Division_Space__c}" required="true"/>
                <apex:inputField value="{!Competitor2__c.Lastname__c}" required="false"/>
                <apex:inputField value="{!Competitor2__c.Date_of_Birth__c}" required="false"/>
                <apex:inputField value="{!Competitor2__c.Waiver_Read_T_Cs_Accepted__c}" required="false"/>
                <apex:inputField value="{!Competitor2__c.Email_Address__c}" required="false"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!Competitor2__c.Phone_Number__c}" required="false"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!Competitor2__c.Street_Address__c}" required="false"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!Competitor2__c.Suburb__c}" required="false"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!Competitor2__c.State__c}" required="false"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!Competitor2__c.Postcode__c}" required="false"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!Competitor2__c.Country__c}" required="false"/>
                <apex:pageBlockSectionItem />
            </apex:pageBlockSection>            
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Best Answer chosen by Sophia G
Santosh Kumar 348Santosh Kumar 348
Hi Sophia,

You can refer the similar thread for your reference
https://salesforce.stackexchange.com/questions/34344/passing-data-from-one-page-to-other-page-in-visualforce

If you still face any issue then do let me know.

Please mark as Best Answer if above information was helpful.

Regards,
Santosh Kumar

All Answers

SFDC_SaurabhSFDC_Saurabh

Modifu below to add
extensions="NFOSController"
 
<apex:pageBlockSection columns="2" showHeader="true" title="Registration" extensions="NFOSController">

 
Sophia GSophia G
You can't add extensions into the pageblock section. I have added it as below. But how do you add this Visualforce page into the controller.
<apex:page standardController="Competitor2__c" extensions="NFOSController" lightningStylesheets="true">
Santosh Kumar 348Santosh Kumar 348
Hi Sophia,

Can you please elaborate a bit what is your ask and give a brief what you ae tring to achieve.

Reagards,
Santosh Kumar
Sophia GSophia G
Hi Santosh,
I am trying to add both Visualforce pages to the same controller so that I can pass an object field value from the list to the registration form when the particular record is selected. The first Visualforce page is of Division Types, and a Competitor selects the one they desire, and it pulls through to the Registration form when they click the next button (I have not added this button in yet, I am just trying to combine both pages on the one controller so that I can attempt this.) Thanks
Santosh Kumar 348Santosh Kumar 348
Hi Sophia,

You can refer the similar thread for your reference
https://salesforce.stackexchange.com/questions/34344/passing-data-from-one-page-to-other-page-in-visualforce

If you still face any issue then do let me know.

Please mark as Best Answer if above information was helpful.

Regards,
Santosh Kumar
This was selected as the best answer