public function actionAdd($id) { $model = new AttributeEnumRecord(); if (request()->isPost) { if ($model->load(request()->post()) && $model->validate()) { $model->rule_id = $this->rule->id; $model->enum_id = AttributeEnumRecord::find()->byRule($this->rule->id)->select(new Expression('MAX(enum_id)'))->scalar() + 1; if ($model->save()) { return $this->redirect(['attributes/attribute', 'id' => $this->rule->id]); } } } return $this->render('update', ['model' => $model]); }