Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Save the member on editing a dataobject

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: 343 Views
  • Pipifix
    Avatar
    Community Member
    54 Posts

    Save the member on editing a dataobject Link to this post

    Hi and Hello.

    I've got a dataobject (projects) on a webpage. And there are a bunch of editors allowed to edit this dataobjects. My client want to see, which single dataobject item is edited by which editor (currentMember). So what i need is a startingpoint (or a simple tutorial) to get this problem solved.
    It is neccesary to use a hook like onBeforeWrite()? Is there something like "lasteditedby"?

    I guess its a simple task but i dont got a clue where to start. Thanks a lot, Pipifix

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: Save the member on editing a dataobject Link to this post

    hi

    you can add a new field to the dataobject, for example "lasteditby"

    and then set a value for it with onBeforeWrite()

    function onBeforeWrite() {
       
    if( $member = Member::currentUser() ) {
    $this->lasteditby = $member->ID;
    }
       
    parent::onBeforeWrite();

    }

    dont tested this, but should point to right direction...

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: Save the member on editing a dataobject Link to this post

    Hi danzzz

    Thanks for your response. I'll give it a try.
    Pipifix

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