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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

trigger creation of a record

Go to End

2 Posts   436 Views


Community Member, 52 Posts

19 January 2014 at 11:49pm

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?


Forum Moderator, 1391 Posts

20 January 2014 at 12:32am

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();