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.

All other Modules /

Discuss all other Modules here.

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

Extending the ModelAdmin_RecordController


Go to End


1426 Views

Avatar
Linkdup

Community Member, 1 Post

21 July 2010 at 4:36pm

I have added the Poll Module to a website and need to make sure that only one poll is active at a time. So I added the onBeforeWrite on the Poll DataObject, thinking that it may do the trick. Unfortuently that did not work. The problem is that it also gets called when the user saves a poll question in the front-end. So everytime someone answers the Poll question it gets de-acativated. I guess that I could do some checks to see if the action is recieved from the CMS or the Frontend and then do some conditional check in the onBeforeWrite method (quick and dirty way). However, I would think it would be much better to extend the Controller class for this purpose. I would assume that it would be fairly common to extend the doSave in the ModelAdmin_RecordController. Does anyone have some sample code for extending the ModelAdmin_RecordController or point me in the right direction. Thanks in advance.