コード例 #1
0
 /**
  * Updates an existing FarmerEducation model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->education_id > 0) {
         $education = Education::findOne($model->education_id);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'education' => $education]);
     }
 }
コード例 #2
0
 /**
  * Finds the Education model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Education the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Education::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: hscstudio/psiaga
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', '<span class=\'glyphicon glyphicon-plus-sign\'></span>  Create Farmer Education'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
$state_id = Yii::$app->user->identity->state_id;
$columns[] = ['class' => 'yii\\grid\\SerialColumn'];
$columns[] = ['attribute' => 'education_id', 'format' => 'raw', 'value' => function ($data) {
    if ($data->education_id > 0) {
        return \app\models\Education::findOne($data->education_id)->name;
    } else {
        return "-";
    }
}];
if ($state_id > 0) {
} else {
    $columns[] = ['attribute' => 'state_id', 'format' => 'raw', 'value' => function ($data) {
        if ($data->state_id > 0) {
            return \app\models\State::findOne($data->state_id)->name;
        } else {
            return "-";
        }
    }];
}
$columns[] = ['attribute' => 'year', 'headerOptions' => ['style' => 'width:75px;', 'class' => 'text-center'], 'contentOptions' => ['class' => 'text-center']];