You need to sign in to do that
Don't have an account?
sales4ce
Cancel button not working as expected
Hi,
I have a visualforce page and a custom controller tied to it.The visualforce page has Account fields of which Account Name field is a required.
Also, i have a cancel button field on my page, when clicked would take the user to account tab.
The issue is, if i do not enter any value in the Account Name field and click cancel, it isn't working and raises a validation error to enter the acocunt name. how can i overcome with this.
Any help is highly appreciated.
Page:
<apex:page controller="cancelActions"> <apex:form > <apex:pageBlock title="Account Information"> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!acctSave}"/> <apex:commandButton value="Cancel" action="{!acctCancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1" > <apex:inputField value="{!acct.Name}"/> <apex:inputField value="{!acct.Type}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Apex Controller:
public class cancelActions {
Public Account acct {get; set;}
Public PageReference acctSave(){
return Null;
}
Public PageReference acctCancel(){
PageReference pg=New PageReference('/001/o');
return pg;
}
}
Thanks,
Sales4ce
I figured out what the problem was. it was the attribute Immediate on the command button.
All Answers
I figured out what the problem was. it was the attribute Immediate on the command button.
public PageReference doCancel(){
pageReference page = new pageReference('/apex/VF Page Name?id='+pagerecord ID);
page.setRedirect(true);
return page;
}