Beispiel #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();
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmFields()
 {
     return $this->hasMany(CmField::className(), ['cm_id' => 'id']);
 }
Beispiel #3
0
echo $form->field($model, 'old_name')->hiddenInput()->label(false);
?>
        <?php 
echo $form->field($model, 'label');
?>
        <?php 
echo $form->field($model, 'hint');
?>
        <?php 
echo $form->field($model, 'data_type')->dropDownList(CmField::dataType(), ['prompt' => Yii::t('app', 'Prompt datatype')]);
?>
        <?php 
echo $form->field($model, 'length')->hint(Yii::t('app', 'useful for string and decimal datatype'));
?>
        <?php 
echo $form->field($model, 'input')->dropDownList(CmField::inputType(), ['prompt' => Yii::t('app', 'Prompt inputtype')]);
?>
        <?php 
echo $form->field($model, 'source')->textarea()->hint(Yii::t('app', 'support key value pair per line or sql statement'));
?>
        <?php 
echo $form->field($model, 'options')->textarea()->hint(Yii::t('app', 'equal Yii Active field options'));
?>
        <div class="form-group">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        </div>
    <?php 
ActiveForm::end();
?>
Beispiel #4
0
?>
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'sort', 'value' => function ($model) {
    //$checkbox = Html::checkbox('fields[]',null,['class'=>'from-control fields','value'=>$model->name]);
    return Html::hiddenInput('fid[]', $model->id) . Html::textInput('sort[]', $model->sort, ['class' => 'form-control field-sort']);
}, 'format' => 'raw'], 'name', 'label', 'hint', ['attribute' => 'is_inner', 'value' => function ($model) {
    $is_inner = CmField::IS_INNER();
    return $is_inner[$model->is_inner];
}], ['attribute' => 'data_type', 'value' => function ($model) {
    $dt = CmField::dataType();
    return $dt[$model->data_type];
}], 'length', ['attribute' => 'input', 'value' => function ($model) {
    $dt = CmField::inputType();
    return $dt[$model->input];
}], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['view' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['field-view', 'id' => $model->id], ['title' => Yii::t('app', 'View')]);
}, 'update' => function ($url, $model, $key) {
    if ($model->is_inner == 1) {
        return '';
    } else {
        return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['field-update', 'id' => $model->id], ['title' => Yii::t('app', 'View')]);
    }
}, 'delete' => function ($url, $model, $key) {
    if ($model->is_inner == 1) {
        return '';
    } else {
        return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['field-delete', 'id' => $model->id, 'cm_id' => $model->cm_id], ['title' => \Yii::t('app', 'Delete'), 'aria-label' => \Yii::t('app', 'Delete'), 'data-pjax' => '0', 'data-confirm' => \Yii::t('app', 'Are you sure you want to delete this item?'), 'data-method' => 'post']);
    }
Beispiel #5
0
 /**
  * Finds the Cm field model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CmField the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findFieldModel($id)
 {
     if (($model = CmField::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }