/** * @inheritdoc */ public function init() { parent::init(); /** * After validation event find out if default has to be set or not. Check if if current value * has default to 1, disabled the other default attributes. */ $this->on(self::EVENT_BEFORE_INSERT, function ($event) { if ($this->is_default == 1) { self::updateAll(['is_default' => 0]); } }); $this->on(self::EVENT_BEFORE_UPDATE, function ($event) { if ($this->is_default == 1) { $this->markAttributeDirty('is_default'); self::updateAll(['is_default' => 0]); } }); }
public function init() { parent::init(); $this->on(self::EVENT_BEFORE_INSERT, [$this, 'eventBeforeInsert']); $this->on(self::EVENT_BEFORE_UPDATE, [$this, 'eventBeforeUpdate']); }
public function init() { parent::init(); $this->on(self::EVENT_BEFORE_DELETE, [$this, 'eventBeforeDelete']); }
public function init() { parent::init(); $this->on(self::EVENT_BEFORE_INSERT, [$this, 'hashContent']); $this->on(self::EVENT_BEFORE_UPDATE, [$this, 'hashContent']); }
public function init() { parent::init(); $this->on(self::EVENT_BEFORE_INSERT, [$this, 'encodePassword']); }
public function init() { parent::init(); $this->on(self::EVENT_BEFORE_INSERT, [$this, 'beforeCreate']); $this->on(self::EVENT_BEFORE_VALIDATE, [$this, 'eventBeforeValidate']); }