/**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Playlist::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
示例#2
0
<?php

if (Playlist::model()->find('uid=' . Yii::app()->user->id)) {
    ?>
<h3>请选择要添加歌曲的播放列表</h3>
<p>立即移动这些歌曲到:</p>
<div class="form">
<?php 
    $form = $this->beginWidget('CActiveForm', array('id' => 'playlist-form', 'enableAjaxValidation' => false));
    echo '<pre>';
    var_dump($_POST);
    echo '</pre>';
    echo $form->dropDownList($model, 'playlist_id', Playlist::getAllofCurrentUser());
    ?>
<input type="hidden" name="id" value="<?php 
    echo $id;
    ?>
" />
	<div class="row buttons">
		<?php 
    echo CHtml::submitButton('保存');
    ?>
	</div>
	
<?php 
    $this->endWidget();
    ?>
</div>
<?php 
} else {
    echo '你还没有播放列表,请先<a href="index.php?r=playlist/create">创建</a>。';
示例#3
0
 public function loadPlaylistModel($id)
 {
     $model = Playlist::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }