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.

Customising the CMS /

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

How to add if condition into ModelAdmin class inheritor?


Go to End


2 Posts   915 Views

Avatar
Bogoed Shamansky

Community Member, 12 Posts

15 November 2014 at 1:03am

Edited: 15/11/2014 1:14am

Now we have DataObject like this:

class Record extends DataObject{
private static $db = array('Account' => 'Int(8)');
}
...

And for CMS back-end:

class RecordAdmin extends ModelAdmin {
    private static $managed_models = array('Record');
    private static $url_segment = 'records';
    private static $menu_title = records';
}

I want to make that In CMS back-end users can add and edit objects from Record table ONLY if current date is between 23 and 27.
Else (in other days) write message, that they can't write now.

How to implement it?

Avatar
Michiel

Community Member, 2 Posts

15 November 2014 at 1:37am

Edited: 15/11/2014 1:40am

You could try the onBeforeWrite() method

See http://doc.silverstripe.org/framework/en/topics/datamodel