示例#1
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionCrear($id)
 {
     $bloque = new Bloque();
     if (isset($_POST['Bloque'])) {
         $bloque->attributes = $_POST['Bloque'];
         if ($bloque->save()) {
             Yii::app()->user->setFlash('success', 'Bloque ' . $bloque->titulo . ' guardado con éxito');
             $this->redirect($_POST['returnUrl'] ? $_POST['returnUrl'] : $this->createUrl('pagina/view', array('id' => $bloque->pgBloques->pagina_id)));
         }
     }
     //if(isset($_POST['Bloque']))
     $pgBloques = $id ? PgBloques::model()->with('pagina')->findByPk($id)->id : 0;
     $bloque->pg_bloques_id = $pgBloques;
     $this->render('crear', array('model' => $bloque));
 }