It looks like it's not registering the updated value in the
$this->changed array so skips over updating anything manually updated in the
Attempting to update another field like
$this->record['title'] = $this->record['title'] . ' test'; doesn't work but shows as updated in the var_dump
First record array has index of 15 while the second has index of 16 with the difference being a 'MigratingVersion` key with null value.
It looks like it's calling the DOs
onBeforeWrite method twice.
Interesting, good to know what it's expecting. Wrapping it in
strtotime doesn't change it. In the
DataObject->write function it sets
$now = DBDatetime::now()->Rfc2822();. I've tried to create the date via
$promotion_date = DBDateTime::create()->setValue($promotion_date)->Rfc2822();. Just before calling
parent::onBeforeWrite() I add
var_dump($promotion_date); which interestingly prints out 2
$record arrays. The first contains the original promo data while the second contains the new date.
Yeah, trying to build a PromotionDate value to be saved in
Hey team, does this seem like valid code to you? I'm stuck with this
onBeforeWrite function which doesn't seem to want to update the database record with the PromotionDate.
Oh, was going to say as a random aside Michal, whether it's right or not, the dev docs show to add the parent call after our code: https://docs.silverstripe.org/en/4/developer_guides/model/extending_dataobjects/#onbeforewrite
Change those field names to something like
onBeforeWrite is called where I can create a date object from those two fields and save it to a single database record.