本文整理汇总了PHP中app\models\ContactForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactForm::validate方法的具体用法?PHP ContactForm::validate怎么用?PHP ContactForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\ContactForm
的用法示例。
在下文中一共展示了ContactForm::validate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$model = new ContactForm();
if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
\Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
} else {
return $this->render('index', ['model' => $model]);
}
}
示例2: actionForm
public function actionForm()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
return $this->render('entry-confirm', ['model' => $model]);
return;
}
}
return $this->render('form', ['model' => $model]);
}
示例3: actionContact
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$body = '<div>Body: <b>' . $model->body . '</b></div>';
$body .= '<div>Email: <b>' . $model->email . '</b></div>';
Yii::$app->common->sendMail($model->subject, $body);
print 'Send success';
die;
}
return $this->render('contact', ['model' => $model]);
}
示例4: actionContact
/**
* @param null|\app\core\admpages\models\Page $modelPage
* @return string|\yii\web\Response
*/
public function actionContact($modelPage = null)
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail()) {
Yii::$app->session->setFlash('success', Yii::t("app/contacts", "Thank you for contacting us. We will respond to you as soon as possible.", ['dot' => false]));
return $this->refresh();
}
Yii::$app->session->setFlash('error', Yii::t("app/contacts", "There was an error sending email.", ['dot' => false]));
}
return $this->render('contact', ['model' => $model, 'modelPage' => $modelPage]);
}
示例5: actionContact
/**
* Displays the contact static page and sends the contact email.
*
* @return string|\yii\web\Response
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', Yii::t('app', 'Thank you for contacting us. We will respond to you as soon as possible.'));
} else {
Yii::$app->session->setFlash('error', Yii::t('app', 'There was an error sending email.'));
}
return $this->refresh();
}
return $this->render('contact', ['model' => $model]);
}
示例6: actionContact
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', '感谢您与我们联系。 我们将尽快回复您.');
} else {
Yii::$app->session->setFlash('error', '送电子邮件时出现错误。');
}
return $this->refresh();
} else {
return $this->render('contact', ['model' => $model]);
}
}
示例7: actionContact
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Dank u voor uw bericht. Wij zullen zo spoedig mogelijk contact met u opnemen.');
} else {
Yii::$app->session->setFlash('error', 'Er ging iets fout met het versturen');
}
return $this->refresh();
} else {
return $this->render('contact', ['model' => $model, 'page' => 'page-contact']);
}
//return $this->render('contact', ['page' => 'page-contact']);
}
示例8: actionContactajax
public function actionContactajax()
{
// FORMAT_HTML , FORMAT_JSON , FORMAT_JSONP , FORMAT_RAW , FORMAT_XML
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$model = new ContactForm();
$isModelLoaded = $model->load(['ContactForm' => Yii::$app->request->post()]);
if ($isModelLoaded && $model->validate()) {
// SET email variables
$body = "";
$body .= "From: " . $model->name . "<br/>";
$body .= "E-mail: " . $model->email . "<br/>";
$body .= "Phone: " . $model->phone . "<br/>";
$model->body = $body . "<br/>" . strip_tags($model->body) . "<br/>";
$model->subject = "[Contact-Form] " . $model->subject;
// SET email settings
$mail = new ChronoMailer("utf-8");
$mail->From(Yii::$app->params['adminEmail']);
$mail->To(Yii::$app->params['adminEmail']);
$mail->Cc(Yii::$app->params['partnerEmail']);
//$mail->Bcc(Yii::$app->params['partnerEmail']);
$mail->Subject($model->subject);
$mail->Body($model->body, 'html');
// OPTIONAL SEND-METHOD :: SMTP
//$mail->smtp_on( 'smtp.copaco.com.py', 'gramacchi', 'ybudxrvv', '587');
//$mail->smtp_on( 'smtp-mail.outlook.com', 'juanchi_008manuel@hotmail.com', 'password', '587');
// SET SMTP TYPE
if ($mail->Send()) {
return 'success';
} else {
return $mail->status_mail['message'];
}
}
$msg = "";
//$msg .= "Yii::app->request->isAjax = ".Yii::$app->request->isAjax.'<br/>';
//$msg .= "isModelLoaded = ".$isModelLoaded.'<br/>';
foreach ($model->errors as $errorField => $errorList) {
if (is_string($errorList)) {
$msg .= $errorField . ' : ' . $errorList . '<br/>';
} elseif (is_array($errorList)) {
foreach ($errorList as $errorMsg) {
$msg .= $errorField . ' : ' . $errorMsg . '<br/>';
}
}
}
return $msg;
}
示例9: actionContact
public function actionContact()
{
$this->layout = 'page';
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$message = new Message();
$message->fullname = $model->fullname;
$message->subject = $model->subject;
$message->email = $model->email;
$message->message = $model->message;
$message->date = time();
$message->insert();
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
} else {
$customData = CustomData::find()->where(['key' => 'contact'])->one();
$contactData = json_decode($customData->value, TRUE);
return $this->render('contact', ['model' => $model, 'contactData' => $contactData]);
}
}