Problem With Timestampbehavior

Hi.

I’m having some troubles with TimestampBehavior.

I configured my model this way, according to here:


    public function behaviors()

    {

        return [[

            'class' => TimestampBehavior::className(),

            'createdAtAttribute' => 'data_inserimento',

            'updatedAtAttribute' => 'data_modifica',

        ],];

    }



this because my form fields are different than the defaults.

With this config the createdAtAttribute is modified on record UPDATE (not insert), no change applied to updatedAtAttribute.

If I change the config to be


    public function behaviors()

    {

        return [[

            'class' => TimestampBehavior::className(),

            'createdAtAttribute' => 'data_inserimento',

            'updatedAtAttribute' => 'data_modifica',

            'attributes' => [

                ActiveRecord::EVENT_BEFORE_INSERT => 'data_inserimento',

                ActiveRecord::EVENT_BEFORE_UPDATE => 'data_modifica',

            ],

        ],];

    }



behaves the same.

What am I doing wrong?

thanks

I fixed by adding




'value' => new Expression('NOW()'),



to the config.

I don’t know if it’s due to kartik’s datecontrol module or what, but the timestamp attributes were strings in the model, so probably the default


time()

wasn’t working…