You need to sign in to do that
Don't have an account?
Amanda Byrne- Carolina Tiger Rescue
setting the default value on a Visual Force page to match the default value of the field
I am trying to modify some VF code to use the field's default value as the default value on the page
Ctrl Code
The page displays all the appropriate values but does not set the default value to the field's default. It's set to --None--
how do I set the default value for the page to the field's default value?
gratefully, A
Ctrl Code
public String mailingCountry {get; set;}
public PageReference saveAttendee(){
public PageReference saveAttendee(){
mailingCountry = attendee.DTCI_Mailing_Country__c;
}
}
VF Page Code
<detail>Mailing Country<font class='detailError'>*</font></detail>
<apex:inputField value="{!CnP_PaaS_EVT__Event_attendee_session__c.DTCI_Mailing_Country__c}" required="true" styleClass="detail" id="mailingCountryField" >
<apex:param name="attendeeMailingCountryParam" value="{!CnP_PaaS_EVT__Event_attendee_session__c.DTCI_Mailing_Country__c}" assignTo="{!mailingCountry}"/>
</apex:inputField>
<apex:inputField value="{!CnP_PaaS_EVT__Event_attendee_session__c.DTCI_Mailing_Country__c}" required="true" styleClass="detail" id="mailingCountryField" >
<apex:param name="attendeeMailingCountryParam" value="{!CnP_PaaS_EVT__Event_attendee_session__c.DTCI_Mailing_Country__c}" assignTo="{!mailingCountry}"/>
</apex:inputField>
The page displays all the appropriate values but does not set the default value to the field's default. It's set to --None--
how do I set the default value for the page to the field's default value?
gratefully, A
In your controller class can you add a public variable of type CnP_PaaS_EVT__Event_attendee_session__c and initialize it from the constructor method of your controller class. For example:
public CnP_PaaS_EVT__Event_attendee_session__c ses {get; set;}
//replace ControllerClass with the name of your controller class
public ControllerClass(){
ses = new CnP_PaaS_EVT__Event_attendee_session__c();
}
From your VF page replace this line:
<apex:inputField value="{!CnP_PaaS_EVT__Event_attendee_session__c.DTCI_Mailing_Country__c}" required="true" styleClass="detail" id="mailingCountryField" >
With this update line:
<apex:inputField value="{!ses.DTCI_Mailing_Country__c}" required="true" styleClass="detail" id="mailingCountryField" >
Let me know if the field displays the default value after the change.
All Answers
In your controller class can you add a public variable of type CnP_PaaS_EVT__Event_attendee_session__c and initialize it from the constructor method of your controller class. For example:
public CnP_PaaS_EVT__Event_attendee_session__c ses {get; set;}
//replace ControllerClass with the name of your controller class
public ControllerClass(){
ses = new CnP_PaaS_EVT__Event_attendee_session__c();
}
From your VF page replace this line:
<apex:inputField value="{!CnP_PaaS_EVT__Event_attendee_session__c.DTCI_Mailing_Country__c}" required="true" styleClass="detail" id="mailingCountryField" >
With this update line:
<apex:inputField value="{!ses.DTCI_Mailing_Country__c}" required="true" styleClass="detail" id="mailingCountryField" >
Let me know if the field displays the default value after the change.