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
Schuey1Schuey1 

Cancel Command Button not working because of required fields

Hello,

I have a VF page associated with a controller extension with the "cancel" method, using PageReference. When I call the cancel method in the VF page, it works well.

However, I get an error message "you must enter a value" when I click on the Cancel button, because some fields on the page are required. If I fill in those fields, I can then cancel without problems.

Does anybody have any idea how to work around that?

Thanks a lot
Best Answer chosen by Admin (Salesforce Developers) 
jwetzlerjwetzler
immediate="true"

All Answers

jwetzlerjwetzler
immediate="true"
This was selected as the best answer
Schuey1Schuey1
Thanks very much Jill!

I have another quick question. Do you happen to know if dependent picklists are supported by VF?

Thanks.
jwetzlerjwetzler
Not currently.  It is on the roadmap though.
Schuey1Schuey1
Ok, thanks for the quick answers.
AltiumForceAltiumForce

I don't seem to need to specify immediate="true" for Cancel button.

 

PageReference setRedirect works fine with required fields blanked out.

 

Visualforce has updated this behaviour?

Shwetal DesaiShwetal Desai
hey Jill Wetzler,

I m facing same problem and i tried your suggestion. but its not working for me.

Still my overrided VF page does not redirected to the standard Tab page.

please help