示例#1
0
?>
			<?php 
echo $form->error($model, 'name');
?>
		</div>
	
			<div class="row">
			<label for="AdminRadioModel_parent_id">Kênh cha</label>
			<?php 
if (!$model->isNewRecord) {
    $allSubRadio = AdminRadioModel::model()->getAllSub($model->id);
} else {
    $allSubRadio = array();
}
$meid = $model->id > 0 ? $model->id : 0;
$items = CHtml::listData(AdminRadioModel::model()->findAll('status=1'), 'id', 'name');
echo '<select name="AdminRadioModel[parent_id]" id="AdminRadioModel_parent_id">';
echo '<option value="0">--None--</option>';
foreach ($items as $key => $item) {
    if ($key == $meid || in_array($key, $allSubRadio)) {
        echo "<option disabled='disabled'>{$item}</option>";
    } else {
        if ($model->parent_id == $key) {
            $selected = "selected";
        } else {
            $selected = "";
        }
        echo "<option value='{$key}' {$selected}>{$item}</option>";
    }
}
echo '</select>';
 /**
  * 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 = AdminRadioModel::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     $pageSize = Yii::app()->request->getParam('pageSize', Yii::app()->params['pageSize']);
     Yii::app()->user->setState('pageSize', $pageSize);
     $channelId = Yii::app()->request->getParam('id', 0);
     $type = AdminRadioModel::model()->findByPk($channelId)->type;
     $model = new AdminRadioCollectionModel('search');
     $model->unsetAttributes();
     // clear any default values
     $model->radio_id = $channelId;
     if (isset($_GET['AdminRadioCollectionModel'])) {
         $model->attributes = $_GET['AdminRadioCollectionModel'];
     }
     $this->render('index', array('model' => $model, 'pageSize' => $pageSize, 'channelId' => $channelId, 'type' => $type));
 }