public function run() { $cs = Yii::app()->getClientScript(); Yii::app()->clientScript->registerCoreScript('jquery'); $this->registerCoreScripts(); $model = MainMenu::model()->findByPK(1); $menu = $model->getTreeViewArray(false, 'id', 1); $this->render($this->itemview, array('menu' => $menu)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = MainMenu::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php echo CHtml::dropDownList('controller', $model->controller, CHtml::listData($items['controllers'], 'name', 'name'), array('prompt' => 'Нет ссылки', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('mainMenu/dynamicActions'), 'update' => '#MainMenu_action', 'beforeSend' => 'function(){ $("#MainMenu_action").empty(); $("#dynelements").empty(); }', 'complete' => 'function(){ $("#MainMenu_controller").val($("#controller option:selected").val()); $("#MainMenu_action").change(); }'))); ?> <?php $actions = array(); if ($model->controller) { $actions = CHtml::listData(MainMenu::model()->getContActions($model->controller), 'name', 'name'); } ?> <?php echo $form->dropDownList($model, 'action', $actions, array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('mainMenu/dynamicElements'), 'update' => '#dynelements', 'complete' => 'function(){ //$("#dynelements").empty(); }'))); ?> <div class="row" id="dynelements"> <?php echo $form->labelEx($model, 'element'); ?> <?php if ($model->controller && $model->action) { echo $model->getActionElements($model->controller, $model->action);