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