You need to sign in to do that
Don't have an account?
Validation Rules for custom controller
Hi gujs.
I use custom visualforce page and class to create new record of my custom object (override standart "new" button to visualforce page ). This object have a sets of validation rules for 5 different fields.
When I leave these fields blank and try to save the object, then validation error displayed but only for one field. If I fill this field with value and save the object, then error is displayed for next unfilled field.
I want to display all errors simultaneously, but not sequental. But have no idea how to do it.
There is a piece of code from my apex class where I instert record
public PageReference SaveEvent(){ try { insert ev; } catch (DmlException e){ ApexPages.addMessages(e); Debug = String.valueOf(e); return null; } ...
Have you set the fields as required via Setup-->Create-->Objects-->My Ojbect? If so, the required validation should be handled automagically. You do not need to write custom logic in a controller to handle it.
Validation rules works, but I if few fields is wrong, visualforce just show error near one field.