Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » trigger creation of a record

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: 128 Views
  • voodoochile
    Avatar
    Community Member
    52 Posts

    trigger creation of a record Link to this post

    Hi all

    I have a dataobject called nuts and another called bolts, I am trying to figure out how when a new entry for nuts is created to also create a new entry for bolts.

    I am thinking to use onafterwrite but not sure of what to use to request the record creation.

    Can anyone please point me in the right direction?

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: trigger creation of a record Link to this post

    Something simple, to get you going, in this case assuming Bolt has a NutID

    $bolt = Bolt::get()->filter(array('NutID' => $this->ID));
    if (!$bolt) {
    $bolt = new Bolt():
    $bolt->NutID = $this->ID;
    ...
    $boltID = $bolt->write();
    }

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