I am trying to use the builtin timestamp behavior. I have an article model. In it I placed:
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\AutoTimestamp',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
],
],
];
}
The result is I can’t create an article as it always shows validation error:
Create Time cannot be blank.
Update Time cannot be blank.
Anybody has an idea what I am missing?
Thanks