posted by aqshakirzhan on January 14, 2015

 

Связи

    public function getChildren() {
        return $this->hasMany(Category::className(), ['ctg_parent_id' => 'ctg_id']);
    }
    public function getParent() {
        return $this->hasOne(Category::className(), ['ctg_id' => 'ctg_parent_id']);
    }

//Связь многие ко многим через вспомогательную таблицу category_kitchen
    public function getKitchens() {

        return $this->hasMany(Kitchen::className(), ['ktn_id' => 'ctkt_kt_id'])
            ->viaTable('category_kitchen', ['ctkt_ctg_id' => 'ctg_id']);
    }


Элементы формы

<?= $form->field($model, 'pst_active')->dropDownList(array(1=>"вкл", 0=>"выкл")); ?>

<?= $form->field($model, 'pst_description')->textArea(['maxlength' => 1023]) ?>


Узнать текущий контроллер в шаблоне

$this->context->id


Текущий action

$this->context->module->controller->action->id


Подключение скриптов и стилей

//указываем, что скрипт требует для работы jQuery

$this->registerJsFile('http://example.com/js/main.js', ['depends' => [\yii\web\JqueryAsset::className()]]);

$this->registerCssFile('/style.css');

$this->registerJs();

$this->registerCss

 

Leave a Comment

Fields with * are required.