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

SS3 required fields on page


Go to End


3 Posts   2077 Views

Avatar
EdP

Community Member, 14 Posts

25 February 2013 at 11:07pm

I have a custom field that I need to be required (and not allow the page to save if it is not present). With SS2 I followed this post's (http://www.silverstripe.org/data-model-questions/show/6128 advice and had the following in my page class (after the statics and before the getCMSFields function:

function getCMSValidator() {
   return new RequiredFields('ConcertDate');
}

This no longer correctly works in SS3 (raises error but does allow a new page to be saved) so I suspect there is a new way? Any help much appreciated.

Avatar
soolan

Community Member, 11 Posts

6 April 2013 at 6:49pm

Edited: 06/04/2013 7:12pm

I have the same problem.

I need to validate a couple of fields in the backend.
But I didn't find any solution.

I found this thicket
http://open.silverstripe.org/ticket/2915
which was set to: WONTFIX 2 weeks ago

can anyone please give us a solution for this issue.

Thanks for your time

Avatar
Ironcheese

Community Member, 36 Posts

24 April 2013 at 8:44pm

In my case

    public function getCMSValidator(){
        return new RequiredFields('Code', 'Name');
    }

worked like a charm.
I'm using SS3.0