本文整理汇总了PHP中ContactForm::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactForm::getErrors方法的具体用法?PHP ContactForm::getErrors怎么用?PHP ContactForm::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactForm
的用法示例。
在下文中一共展示了ContactForm::getErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionContact
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$subject = 'Welcome to Wow Cleans';
$body = $this->renderPartial('contactEmail', array('model' => $model), true);
//echo "<pre>";print_r($body);die;
Yii::app()->mailer->send($model->email, $subject, $body);
Yii::app()->user->setFlash('success', "Successfully send your message.");
$this->refresh();
} else {
$errors = $model->getErrors();
//echo var_dump($errors);
}
}
$links = CmsPages::model()->findAll();
Yii::app()->params['MyArray'] = $links;
$this->render('contact', array('model' => $model));
}
示例2: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = CustomPage::LoadByRequestUrl('contact-us');
$this->pageTitle = $model->PageTitle;
$this->pageDescription = $model->meta_description;
$this->breadcrumbs = array($model->title => $model->RequestUrl);
$this->layout = "//layouts/column" . $model->column_template;
$ContactForm = new ContactForm();
if (isset($_POST['ContactForm'])) {
$ContactForm->attributes = $_POST['ContactForm'];
if ($ContactForm->validate()) {
$objEmail = new EmailQueue();
if (!Yii::app()->user->isGuest) {
$objCustomer = Customer::GetCurrent();
$objEmail->customer_id = $objCustomer->id;
$ContactForm->fromName = $objCustomer->mainname;
$ContactForm->fromEmail = $objCustomer->email;
}
$strHtmlBody = $this->renderPartial('/mail/_contactform', array('model' => $ContactForm), true);
$strSubject = Yii::t('email', 'Contact Us:') . $ContactForm->contactSubject;
$objEmail->htmlbody = $strHtmlBody;
$objEmail->subject = $strSubject;
$orderEmail = _xls_get_conf('ORDER_FROM', '');
$objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail;
$objHtml = new HtmlToText();
//If we get back false, it means conversion failed which 99.9% of the time means improper HTML.
$strPlain = $objHtml->convert_html_to_text($strHtmlBody);
if ($strPlain !== false) {
$objEmail->plainbody = $strPlain;
}
if (!$objEmail->save()) {
Yii::log("Error creating email " . print_r($objEmail, true) . " " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
}
Yii::app()->user->setFlash('success', Yii::t('email', 'Message sent. Thank you for contacting us. We will respond to you as soon as possible.'));
//Attempt to use an AJAX call to send the email. If it doesn't work, the Download process will catch it anyway.
$jsScript = "\$.ajax({url:\"" . CController::createUrl('site/sendemail', array("id" => $objEmail->id)) . "\"});";
Yii::app()->clientScript->registerScript('sendemail', $jsScript, CClientScript::POS_READY);
} else {
Yii::app()->user->setFlash('error', Yii::t('cart', 'Please check your form for errors.'));
if (YII_DEBUG) {
Yii::app()->user->setFlash('error', print_r($ContactForm->getErrors(), true));
}
}
}
if (!Yii::app()->user->isGuest) {
$objCustomer = Customer::GetCurrent();
$ContactForm->fromName = $objCustomer->mainname;
$ContactForm->fromEmail = $objCustomer->email;
}
$this->canonicalUrl = $model->canonicalUrl;
$this->render('contact', array('ContactForm' => $ContactForm, 'model' => $model));
}