/** * @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(); }
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'is_real')->inline(true)->radioList(Node::isReal())->hint(Yii::t('app', 'V Nodes can link other real nodes'), ['class' => 'help-block col-lg-offset-2 col-lg-10']); ?> <?php echo $form->field($model, 'v_nodes')->textarea(['rows' => 2]); ?> <?php echo Html::activeHiddenInput($model, 'parent'); ?> <?php echo $form->field($model, 'cm_id')->dropDownList(ArrayHelper::map(Cm::find()->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Please select content model')])->hint(Yii::t('app', 'When selected ,can not modify')); ?> <?php echo $form->field($model, 'parent_txt')->textInput(['placeHolder' => Yii::t('app', 'Please input Node id or Node name to select') . Yii::t('app', 'When selected ,can not modify')]); ?> <?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'workflow')->dropDownList(ArrayHelper::map(Workflow::find()->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Please select workflow')]); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getCm() { return $this->hasOne(Cm::className(), ['id' => 'cm_id']); }
/** * 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.'); } }
/* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Content Model'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="cm-index"> <p> <?php echo Html::a(Yii::t('app', 'Create Cm'), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name', 'tab', ['attribute' => 'is_inner', 'value' => function ($model) { $is_inner = Cm::IS_INNER(); return $is_inner[$model->is_inner]; }], 'site.name', ['attribute' => 'tab_index', 'value' => function ($model) { $tab_index = Cm::$TAB_INDEX; return $tab_index[$model->tab_index]; }], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['update' => function ($url, $model, $key) { if ($model->is_inner == 1) { return ''; } else { return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['update', 'id' => $model->id], ['title' => Yii::t('app', 'Update')]); } }, 'field' => function ($url, $model, $key) { return Html::a('<span class="fa fa-th-list"></span>', ['field', 'id' => $model->id], ['title' => Yii::t('app', 'Field list view')]); }, 'delete' => function ($url, $model, $key) { if ($model->is_inner == 1) { return '';