/** * Creates a new Meta model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Meta(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * @return mixed the value of the given option or the default, if none */ public function getOption($name, $defaultValue = null, $returnModel = false) { $data = ['name' => $name, 'parent_class' => self::className(), 'parent_id' => $this->id]; $meta = Meta::findOne($data); if ($returnModel) { if (!isset($meta)) { $meta = new Meta(); $data['value'] = $defaultValue; $meta->load(['data' => $data], 'data'); } return $meta; } else { return isset($meta) ? $meta->value : $defaultValue; } }