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.

All other Modules /

Discuss all other Modules here.

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

Extending the ModelAdmin_RecordController


Reply


868 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.