Jump to:

23355 Posts in 17702 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Detect if DataObject has changed

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 697 Views
  • Mo
    Avatar
    Community Member
    504 Posts

    Detect if DataObject has changed Link to this post

    Hi All,

    I am trying to write an Akismet module for comments (SS3). Repo can be found here:

    https://github.com/i-lateral/silverstipe-akismet

    Using a lot of butchered 2.4 code at the mo, but managed to get it reporting a spam post by extending a comment's onBeforeWrite().

    I need to get the report spam and report ham functionality working though, but I am not sure if I can detect if the Comment object has changed from within onBeforeWrite()?

    Any ideas? Would love to get this released.

    Cheers,

    Mo

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: Detect if DataObject has changed Link to this post

    $this->owner->isChanged(), or $this->owner->isChanged('FieldName');

  • Mo
    Avatar
    Community Member
    504 Posts

    Re: Detect if DataObject has changed Link to this post

    Oooo, cool!

    Cheers Simon, I will get on and fiddle with this as soon as!

    697 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.