/** * Creates a new Contactos model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Contactos(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionNuevocontacto() { $model = new Contactos(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail(Yii::$app->params['adminEmail'])) { $model->save(); Yii::$app->session->setFlash('success', 'Su mensaje fue enviado con exito'); } else { Yii::$app->session->setFlash('error', 'Ha ocurrido un error al enviar el mensaje por favor intente mas tarde'); } return $this->refresh(); } else { return $this->render('nuevocontacto', ['model' => $model]); } }