当前位置: 首页>>代码示例>>PHP>>正文


PHP AForm::validateFormData方法代码示例

本文整理汇总了PHP中AForm::validateFormData方法的典型用法代码示例。如果您正苦于以下问题:PHP AForm::validateFormData方法的具体用法?PHP AForm::validateFormData怎么用?PHP AForm::validateFormData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AForm的用法示例。


在下文中一共展示了AForm::validateFormData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _validate

 /**
  * @return bool
  */
 private function _validate()
 {
     $this->error = array_merge($this->form->validateFormData($this->request->post), $this->error);
     if (!$this->error) {
         return TRUE;
     } else {
         $this->form->setErrors($this->error);
         return FALSE;
     }
 }
开发者ID:vglide,项目名称:abantecart-src,代码行数:13,代码来源:contact.php

示例2: _validate

 /**
  * @return bool
  */
 private function _validate()
 {
     $this->error = array_merge($this->form->validateFormData($this->request->post), $this->error);
     $this->extensions->hk_ValidateData($this);
     if (!$this->error) {
         return true;
     } else {
         $this->form->setErrors($this->error);
         return false;
     }
 }
开发者ID:siddht1,项目名称:abantecart-src,代码行数:14,代码来源:contact.php

示例3: main

 public function main()
 {
     $this->loadModel('tool/forms_manager');
     $this->loadLanguage('forms_manager/forms_manager');
     $this->loadLanguage('forms_manager/default_email');
     if ($this->request->is_POST()) {
         $path = $_SERVER['HTTP_REFERER'];
         if (!isset($this->request->get['form_id'])) {
             $this->redirect($path);
             exit;
         }
         $form_id = $this->request->get['form_id'];
         $form_data = $this->model_tool_forms_manager->getForm($form_id);
         $form = new AForm($form_data['form_name']);
         $form->loadFromDb($form_data['form_name']);
         $errors = $form->validateFormData($this->request->post);
         if ($errors) {
             //save error and data to session
             $this->session->data['custom_form_' . $form_id] = $this->request->post;
             $this->session->data['custom_form_' . $form_id]['errors'] = $errors;
             $this->redirect($path);
             exit;
         } else {
             $mail = new AMail($this->config);
             $mail->setTo($this->config->get('store_main_email'));
             if (isset($this->request->post['email'])) {
                 $mail->setFrom($this->request->post['email']);
                 unset($this->request->post['email']);
             } else {
                 $sender_email = $this->config->get('forms_manager_default_sender_email');
                 $sender_email = !$sender_email ? $this->config->get('store_main_email') : $sender_email;
                 $mail->setFrom($sender_email);
             }
             if (isset($this->request->post['first_name'])) {
                 $mail->setSender($this->request->post['first_name']);
                 unset($this->request->post['first_name']);
             } else {
                 $sender_name = $this->config->get('forms_manager_default_sender_name');
                 $sender_name = !$sender_name ? $this->config->get('store_name') : $sender_name;
                 $mail->setSender($sender_name);
             }
             if (isset($this->request->post['email_subject'])) {
                 $mail->setSubject($this->request->post['email_subject']);
                 unset($this->request->post['email_subject']);
             } else {
                 $mail->setSubject($form_data['form_name']);
             }
             $msg = $this->config->get('store_name') . "\r\n" . $this->config->get('config_url') . "\r\n";
             $fields = $this->model_tool_forms_manager->getFields($form_id);
             foreach ($fields as $field) {
                 // skip files and captchas
                 if (in_array($field['element_type'], array('K', 'J', 'U'))) {
                     continue;
                 }
                 if (isset($this->request->post[$field['field_name']])) {
                     $val = $this->request->post[$field['field_name']];
                     $val = $this->_prepareValue($val);
                     //for zones
                     if ($field['element_type'] == 'Z') {
                         $msg .= $field['name'] . ': ' . $val . "";
                         $val = $this->request->post[$field['field_name'] . '_zones'];
                         $val = $this->_prepareValue($val);
                         $msg .= "\t" . $val . "\r\n";
                     } else {
                         $msg .= $field['name'] . ': ' . $val . "\r\n";
                     }
                 }
             }
             // add attachments
             $file_pathes = $form->processFileUploads($this->request->files);
             if ($file_pathes) {
                 $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
                 foreach ($file_pathes as $file_info) {
                     $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                     $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                     $mail->addAttachment($file_info['path'], $basename);
                 }
             }
             $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
             $mail->send();
             if (empty($mail->error)) {
                 if ($form_data['success_page']) {
                     $success_url = $this->html->getSecureURL($form_data['success_page']);
                 } else {
                     $success_url = $this->html->getSecureURL('forms_manager/default_email/success');
                 }
                 //clear form session
                 unset($this->session->data['custom_form_' . $form_id]);
                 $this->redirect($success_url);
                 exit;
             } else {
                 $this->session->data['warning'] = $mail->error;
                 $this->redirect($this->html->getSecureURL('forms_manager/default_email', '&form_id=' . $form_id));
                 exit;
             }
         }
     }
     $this->data['warning'] = $this->session->data['warning'];
     if (isset($this->session->data['warning'])) {
         unset($this->session->data['warning']);
//.........这里部分代码省略.........
开发者ID:InquisitiveQuail,项目名称:abantecart-src,代码行数:101,代码来源:default_email.php


注:本文中的AForm::validateFormData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。