I’m currently developing a form on salesforce.com using an apex form with a custom extension.
The form itself is designed to book tours that have a maximum number of slots. When the form is submitted, I need to check to make sure that there are still slots available (as in none have been booked between loading the form and submission) for the date and time selected in the form.
I am having trouble having the custom controller receive the submitted form data when PageReference save() is called.
Let’s say I have…
<apex:form>
<apex:pageBlock>
<apex:inputField value="{!customObject__c.Date__c}"/>
<apex:inputField value="{!customObject__c".Time__c}"/>
<apex:commandButton value="{!save}"/>
</apex:pageBlock>
</apex:form>
and my customer extension frame is
public class myExtension {
public myExtension(ApexPages.StandardController controller) {
}
public PageReference save(){
return null;
}
}
How would I go about having the inputField values accessed by save() so I can run a query against the existing database objects?
Any examples of how this would be/has been achieved would be great.
Your visual force markup is incorrect. You need to set the action property with the method and the value attribute will be the save text:
But assuming the above is just a typo you need to have a reference to the object that was passed in by the standard controller: