Esempio n. 1
0
 /**
  * @param $id
  */
 public static function setCm($id)
 {
     $cm = Cm::findOne($id);
     $table = Cm::getTable($cm->tab_index, $cm->tab);
     self::$_tableName = $table;
     self::$_rules = self::getRulesFromString($cm->rules, $table);
     self::$_select_field = $cm->select_field;
     self::$_title_field = $cm->title_field;
     self::$_adv_field = $cm->adv_field;
     $fields = CmField::find()->where(['cm_id' => $id])->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->asArray()->all();
     self::$_fields = self::getOptions($fields);
     return new static();
 }
Esempio n. 2
0
 /**
  * Finds the Cm model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cm the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cm::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }