Важно! Я заметил в отладчике, что после сохранения модели поля дат не пустые!!! Но в базу данных все равно записываются нули. Это очень странно...
Вот моя модель:
Код: Выделить всё
/**
* @property integer $id
* @property integer $category_id
* @property integer $user_id
* @property integer $status_id
* @property string $name
* @property string $text
* @property integer $created_at
* @property integer $updated_at
*/
class Article extends ActiveRecord {
public static function tableName() {
return '{{%article}}';
}
public function behaviors() {
return [
'timestamp' => TimestampBehavior::class,
];
}
public function rules() {
return [
['id', 'safe'],
[['name', 'category_id'], 'required'],
['user_id', 'default', 'value' => Yii::$app->user->id],
];
}
}