intersvyaz / yii-old-attribute-behavior
Yii old attribute behavior.
v1.0.0
2015-03-23 14:44 UTC
Requires
- php: >=5.4.0
- yiisoft/yii: ~1.1.15
This package is auto-updated.
Last update: 2024-11-08 06:02:22 UTC
README
Example usage:
class User extends CActiveRecord { /** * @inheritdoc */ public function behaviors() { return array_merge( parent::behaviors(), [ 'oldBehavior' => ['class' => Intersvyaz\Behavior\OldAttributesBehavior::class], ] ); } /** * @inheritdoc */ protected function afterSave() { if ($this->isModified('username')) { // some your logic $oldValue = $this->old->username; // or $oldValue = $this->oldAttributes['username']; // new value in $this->username } parent::afterSave(); } }