echo " selected ";
}
?>
value="<?php 
echo Constants::STATUS_HIDDEN;
?>
">Скрытый</option>
            </select>
        </div>
        <div class="hr"></div>

        <label class="top-field-label">Выбор категории:</label>

        <?php 
$selected_cat = '';
if ($item->getIsNewRecord()) {
    $selected_cat = $current_tree;
} else {
    $selected_cat = $item->tree_id;
}
?>

        <div class="select-box">
            <select name="tree_id">
                <option <?php 
if ($selected_cat == '') {
    echo " selected ";
}
?>
 value="">Нет</option>
                <?php 
 public function actionUpdatePage()
 {
     /* @var $item ContentUnit */
     //get parameters from request
     $id = Yii::app()->request->getParam('id', null);
     $label = Yii::app()->request->getParam('label', '');
     $status = Yii::app()->request->getParam('status', Constants::STATUS_HIDDEN);
     $tree_id = Yii::app()->request->getParam('tree_id', '');
     //get multi-language arrays
     $titles = Yii::app()->request->getParam('title', array());
     $texts = Yii::app()->request->getParam('text', array());
     //try find by id
     $item = ContentUnit::model()->findByPk($id);
     //if not found - that means we need create
     if ($item == null) {
         $item = new ContentUnit();
     }
     //changed category or not
     $changed = false;
     if (!$item->getIsNewRecord() && $item->tree_id != $tree_id) {
         $changed = true;
     }
     //set main params
     $item->label = $label;
     $item->status = $status;
     $item->type = Constants::TYPE_TEXT_BLOCK;
     $item->tree_id = $tree_id;
     //upload thumbnail
     $old_f_name = $item->thumb;
     $new_f_name = DwHelper::uploadPicAndGetPath($_FILES, 'thumbnail', $old_f_name);
     if ($new_f_name != "") {
         $item->thumb = $new_f_name;
     }
     //if this is creation
     if ($item->getIsNewRecord()) {
         //set new priority considering category
         if ($tree_id != '') {
             $item->priority = DwHelper::getNextPriorityComplex("ContentUnit", $tree_id, "tree_id");
         } else {
             $item->priority = DwHelper::getNextPriority("ContentUnit");
         }
         //set dates
         $item->date_created = time();
         $item->date_changed = time();
         //save
         $item->save();
     } else {
         //if changed category - get next priority in category
         if ($changed) {
             $item->priority = DwHelper::getNextPriorityComplex("ContentUnit", $tree_id, "tree_id");
         }
         //set date of changing
         $item->date_changed = time();
         //update
         $item->update();
     }
     //get language objects
     foreach (Constants::GetLngArray() as $lng) {
         //get lng object
         $itemLng = $item->getLngObject($lng);
         //set data
         $itemLng->title = $titles[$lng];
         $itemLng->text = $texts[$lng];
         //update or create if not exist
         if ($itemLng->getIsNewRecord()) {
             $itemLng->save();
         } else {
             $itemLng->update();
         }
     }
     //prefix for category in url
     $prefixRedirect = "";
     //if have category - set url prefix
     if ($tree_id != '') {
         $prefixRedirect = "/cat/" . $tree_id;
     }
     //back to list
     $this->redirect($this->createUrl('/admin/panel/pageslist' . $prefixRedirect));
 }