IsAttributeChanged not working in aftersave

Hi all,

In the beforeSave function the $this->isAttributeChanged function works properly but in the afterSave function not.

And Unfortunately I cannot get the old attribues in the afterSave function too…

Is it possible to get somehow the information about which attributes have new value?





/**

     * {@inheritdoc}

     */

    public function beforeSave($insert) {

        // this is TRUE

        var_dump($this->isAttributeChanged('about'));

        return parent::beforeSave($insert);

    }


    /**

     * {@inheritdoc}

     */

    public function afterSave($insert, $changedAttributes)

    {

        parent::afterSave($insert, $changedAttributes);

        if (!$insert) {

            // This is FALSE

            var_dump($this->isAttributeChanged('about'));

        }

    }




Unfortunately I would like to run a microservice after the model save and before it.

What Yii is telling you is “the attribute hasn’t changed since the last save”. Which is correct. You’ll have to “remember” it elsewhere.