Example #1
0
 public function actionCreate()
 {
     $model = new CategoryField(['scenario' => 'admin-create']);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             return $this->redirect(Url::toRoute('index'));
         }
     }
     return $this->render('create', ['model' => $model]);
 }
Example #2
0
<?php

use yii\grid\GridView;
use yii\bootstrap\Html;
use yii\helpers\Url;
use yii\easyii\modules\catalog\models\CategoryField;
/**
 * @var \yii\data\ActiveDataProvider $fieldsDP
 * @var \yii\base\View               $this
 */
?>

    <ul class="nav nav-pills">
        <li>
            <?php 
echo Html::a('<i class="glyphicon glyphicon-chevron-left"></i>' . Yii::t('easyii/catalog', 'Catalog'), Url::to(['/admin/' . $this->context->module->id]));
?>
        </li>
        <li>
            <?php 
echo Html::a(Html::button('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('easyii/catalog', 'Fields|Menu|Add'), ['class' => 'btn btn-primary', 'style' => 'float: left', 'type' => 'submit']), Url::toRoute('create'));
?>
        </li>
    </ul>

<?php 
echo GridView::widget(['dataProvider' => $fieldsDP, 'columns' => [['attribute' => 'id', 'headerOptions' => ['width' => 50]], '_id', 'title', 'title_system', ['headerOptions' => ['width' => 110], 'format' => 'raw', 'attribute' => 'type', 'value' => function (CategoryField $field) {
    return CategoryField::types()[$field->type];
}], ['headerOptions' => ['width' => 110], 'attribute' => 'unit'], ['attribute' => 'group_id', 'value' => 'group.title_system'], ['headerOptions' => ['width' => 90], 'class' => \yii\easyii\components\grid\ActionColumn::class, 'template' => '{update} {delete}']]]);
Example #3
0
?>

<?php 
echo $form->field($model, 'title_system');
?>

<?php 
echo $form->field($model, 'unit');
?>

<?php 
echo $form->field($model, 'show_unit')->checkbox();
?>

<?php 
echo $form->field($model, 'type')->dropDownList(CategoryField::types());
?>

<?php 
echo $form->field($model, 'options')->textarea(['rows' => 6]);
?>

<?php 
echo $form->field($model, 'group_id')->dropDownList(\yii\helpers\ArrayHelper::map(CategoryFieldGroup::find()->all(), 'id', 'title_system'));
?>

<?php 
echo $form->field($model, 'required')->checkbox();
?>

<?php