/** * If the 'add default blocks' checkbox was not set (ie not checked in UI) then set it to 0 on the model */ public function onBeforeWrite() { if (!\Controller::curr()->getRequest()->postVar(self::SingleFieldName)) { $this()->{self::SingleFieldName} = 0; } // pick this up in onAfterWrite $this()->WasNew = !$this()->isInDB(); parent::onBeforeWrite(); }
/** * If the ModelTag field is empty (length 0) then fill it with generated value. */ public function onBeforeWrite() { parent::onBeforeWrite(); if (0 === strlen($this()->{static::SingleFieldName})) { $this()->{static::SingleFieldName} = $this->generateValue(); } }