コード例 #1
0
ファイル: TucaoCategory.php プロジェクト: houyf/class_system
 static function categoryOptions()
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'tucao_cate_id, tucao_cate_name';
     $model = TucaoCategory::model()->findAll();
     $cates = array('' => '请选择吐槽类型');
     foreach ($model as $row) {
         $cates[$row->tucao_cate_id] = $row->tucao_cate_name;
     }
     return $cates;
 }
コード例 #2
0
 /**
  * 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 $id the ID of the model to be loaded
  * @return TucaoCategory the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TucaoCategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #3
0
 public function actionTucao($cate_id = -1, $self = false)
 {
     // 全部吐槽分类
     // 自己来吐槽
     if ($self == true) {
         $_GET['cateI_id'] = $cate_id;
         $model = new Tucao();
         if (isset($_POST['Tucao'])) {
             $model->attributes = $_POST['Tucao'];
             $model->save() or die('发布失败');
             $this->redirect(array('index/tucao'));
         }
         $this->render('createTucao', array('model' => $model));
     } else {
         if ($cate_id == -1) {
             $criteria = new CDbCriteria();
             $criteria->addCondition('class_id=' . Yii::app()->user->class_id);
             $model = TucaoCategory::model()->findAll($criteria);
             $this->render('tucaoCategory', array('model' => $model));
         } else {
             $_GET['cate_id'] = $cate_id;
             $_GET['cate_name'] = TucaoCategory::model()->findByPk($cate_id)->tucao_cate_name;
             $criteria = new CDbCriteria();
             $criteria->addCondition('tucao_cate_id=' . $cate_id);
             $criteria->limit = 10;
             $model = Tucao::model()->findAll($criteria);
             $this->render('tucaos', array('model' => $model));
         }
     }
 }
コード例 #4
0
ファイル: _form.php プロジェクト: houyf/class_system
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'tucao-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'tucao_cate_id');
?>
		<?php 
echo $form->dropDownList($model, 'tucao_cate_id', TucaoCategory::categoryOptions());
?>
		<?php 
echo $form->error($model, 'tucao_cate_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'content');
?>
		<?php 
echo $form->textArea($model, 'content');
?>
		<?php 
echo $form->error($model, 'content');