本文整理汇总了PHP中app\models\Contact::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::getErrors方法的具体用法?PHP Contact::getErrors怎么用?PHP Contact::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Contact
的用法示例。
在下文中一共展示了Contact::getErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionContact
public function actionContact()
{
/*$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
} else {
return $this->render('contact', [
'model' => $model,
]);
}*/
if (isset($_POST['nombre']) && isset($_POST['apellido']) && isset($_POST['email']) && isset($_POST['celular']) && isset($_POST['tipo']) && isset($_POST['mensaje'])) {
$contact = new Contact();
$contact->type = $_POST['tipo'];
$contact->name = $_POST['nombre'];
$contact->lastname = $_POST['apellido'];
$contact->email = $_POST['email'];
$contact->cellphone = $_POST['celular'];
$contact->message = $_POST['mensaje'];
if ($contact->type == 'Reclamo') {
if (isset($_POST['cedula'])) {
$contact->identity = $_POST['cedula'];
} else {
echo "no cedula";
}
}
if ($contact->save()) {
/*$body='Tipo: '.$contact->type.'\n';
if($contact->identity!=''){
$body.='Cedula: '.$contact->identity;
}
$body.='Nombre: '.$contact->name.'\n'.
'Apellido: '.$contact->lastname.'\n'.
'Email: '.$contact->lastname.'\n'.
'Cellphone: '.$contact->cellphone.'\n'.
'Mensaje: '.$contact->message.'\n';*/
if (Yii::$app->mailer->compose('contact/contact', ['contact' => $contact])->setFrom([Yii::$app->params['adminEmail'] => 'Optica los Andes'])->setTo('1800optica@ola.ec')->setSubject('Contacto Optica los Andes')->send()) {
echo "enviado";
} else {
echo "no enviado";
}
} else {
echo "no save";
print_r($contact->getErrors());
}
} else {
echo "no post";
}
}