Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

validation for new data object


Go to End


989 Views

Avatar
Nicolaas

Forum Moderator, 224 Posts

16 November 2011 at 1:19pm

Hi

What is the best practice for validating objects - for example, if you want to make sure that a data object always has a "date of birth" entered. I know how to add "required fields" to a form - but what if you just want to validate data objects no matter how they are entered.

I use the validate method, like this: http://pastie.org/2869826 - but this only works for "previously created" objects and not for new objects (at least when adding it through modeladmin).

Am I missing anything?

--
Nicolaas