Revision #3 has been created by Ivo Renkema on Jun 6, 2013, 7:13:50 PM with the memo:
added $this->updated = new Expression('NOW()'); to final method definition of ::beforeSave()
« previous (#2) next (#4) »
Changes
Title
unchanged
Creating a Simple CRUD App With Yii2
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
yii2, tutorial, howto
Content
changed
[...]
```php
public function beforeSave($insert)
{
if ($this->isNewRecord)
{
$this->created = new Expression('NOW()');
}
$this->updated = new Expression('NOW()');
return parent::beforeSave($insert);
}
```
Now try saving again. Our model now has validation on both the title, and content fields, and will automatically update the created and update time for you. Now lets do updating.[...]