protected function findModel($id)
 {
     if (($model = FieldVariant::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested field does not exist.');
     }
 }
Exemplo n.º 2
0
 public function flush()
 {
     $this->fieldVariants = [];
     $values = FieldValue::find()->where(['item_id' => $this->owner->id])->with('field')->all();
     foreach ($values as $value) {
         if ($value->variant_id) {
             $this->fieldVariants[$value->field->slug] = FieldVariant::findOne($value->variant_id)->value;
         } else {
             $this->fieldVariants[$value->field->slug] = $value->value;
         }
     }
     return true;
 }
Exemplo n.º 3
0
 public static function saveEdit($id, $name, $value)
 {
     $setting = FieldVariant::findOne($id);
     $setting->{$name} = $value;
     $setting->save();
 }