コード例 #1
0
 /**
  * Creates a new SedeDomicilio model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $establecimiento_id
  * @param integer $sede_id
  * @return mixed
  */
 public function actionCreate($establecimiento_id, $sede_id)
 {
     $sede = Sede::findOne(['establecimiento_id' => $establecimiento_id, 'id' => $sede_id]);
     $model = new Domicilio(['scenario' => 'sede']);
     // Para validar sólo lo referente a SedeDomicilio
     $model->sede = $sede;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['establecimientos/' . $sede->establecimiento_id . '/sedes/' . $sede->id . '/domicilios/view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'sede' => $sede]);
     }
 }
コード例 #2
0
ファイル: SedesController.php プロジェクト: sacuriom/alba2
 /**
  * Finds the Sede model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $establecimiento_id
  * @param integer $id
  * @return Sede the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($establecimiento_id, $id)
 {
     if (($model = Sede::findOne(['establecimiento_id' => $establecimiento_id, 'id' => $id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }