/** * Updates an existing Parametro model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionEditar($id) { $model = $this->findModel($id); $new = new Parametro(); $new->setAttributes(['nombre' => $model->nombre, 'valor' => $model->valor]); if ($new->load(Yii::$app->request->post())) { $new->fecha_inicio = date('Y-m-d H:i:s'); $model->fecha_fin = date('Y-m-d H:i:s'); $model->status = Parametro::INACTIVO; if ($new->validate()) { $model->save(); $new->save(); return $this->redirect(['ver', 'id' => $new->id]); } } return $this->render('editar', ['id' => $model->id, 'model' => $new]); }