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


PHP EmailField::setValue方法代码示例

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


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

示例1: McSubscribeForm

 /**
  * Create the subscription form
  * @return \Form
  */
 public function McSubscribeForm()
 {
     $fieldsArr = array();
     $email = new EmailField('Email', 'Email');
     $email->setValue('Your e-mail');
     array_push($fieldsArr, $email);
     if (Config::inst()->get('MailChimpController', 'country')) {
         $country = new CountryDropdownField('Country', 'Country');
         array_push($fieldsArr, $country);
     }
     if (Config::inst()->get('MailChimpController', 'topics')) {
         $topicsArr = Config::inst()->get('MailChimpController', 'topicsArr');
         $topics = new CheckboxSetField($name = "Topics", $title = "I am interested in the following topics", $topicsArr, $value = NULL);
         array_push($fieldsArr, $topics);
     }
     if (Config::inst()->get('MailChimpController', 'otherTopic')) {
         $otherTopic = new TextField('Other', '');
         array_push($fieldsArr, $otherTopic);
     }
     $fields = new FieldList($fieldsArr);
     $actions = new FieldList(new FormAction('McDoSubscribeForm', 'Send Now'));
     $required = new RequiredFields(array('Email'));
     $form = new Form($this, 'McSubscribeForm', $fields, $actions, $required);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:zirak-silverstripe-mailchimp,代码行数:29,代码来源:MailChimpController.php

示例2: internalCheck

 public function internalCheck($email, $checkText, $expectSuccess)
 {
     $field = new EmailField("MyEmail");
     $field->setValue($email);
     $val = new EmailFieldTest_Validator();
     try {
         $field->validate($val);
         // If we expect failure and processing gets here without an exception, the test failed
         $this->assertTrue($expectSuccess, $checkText . " (/{$email}/ passed validation, but not expected to)");
     } catch (Exception $e) {
         if ($e instanceof PHPUnit_Framework_AssertionFailedError) {
             throw $e;
         } else {
             if ($expectSuccess) {
                 $this->assertTrue(false, $checkText . ": " . $e->GetMessage() . " (/{$email}/ did not pass validation, but was expected to)");
             }
         }
     }
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:19,代码来源:EmailFieldTest.php

示例3: submit

 /**
  * Save the changes to the form
  */
 function submit($data, $form)
 {
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     $member = Member::currentUser();
     $newMember = false;
     Session::set("FormInfo.Form_Form.data", $data);
     $emailField = new EmailField("Email");
     $emailField->setValue($data["Email"]);
     if ($emailField) {
         if (!$emailField->validate($form->validator)) {
             $form->addErrorMessage("Blurb", $this->ErrorBadEmail, "bad");
             $this->redirectBack();
             return;
         }
     }
     if (!$member) {
         $newMember = true;
         $member = Object::create('Member');
         $form->sessionMessage($this->WelcomeTitle, 'good');
         $id = 0;
     } else {
         $form->sessionMessage($this->ThankYouTitle, 'good');
         $id = $member->ID;
     }
     //validation
     if ($existingMember = Member::get()->filter(array("Email" => Convert::raw2sql($data['Email'])))->exclude(array("ID" => $id))->first()) {
         $form->addErrorMessage("Blurb", $this->ErrorEmailAddressAlreadyExists, "bad");
         return $this->redirectBack();
     }
     // check password fields are the same before saving
     if ($data["Password"]["_Password"] != $data["Password"]["_ConfirmPassword"]) {
         $form->addErrorMessage("Password", $this->ErrorPasswordDoNotMatch, "bad");
         return $this->redirectBack();
     }
     if (!$id && !$data["Password"]["_Password"]) {
         $form->addErrorMessage("Password", $this->ErrorMustSupplyPassword, "bad");
         return $this->redirectBack();
     }
     $password = $member->Password;
     if (isset($data["Password"]["Password"]) && strlen($data["Password"]["Password"]) > 3) {
         $password = $data["Password"]["Password"];
     }
     $form->saveInto($member);
     $member->changePassword($password);
     $member->write();
     if ($newMember) {
         $form->saveInto($member);
         $member->write();
     }
     //adding to group
     $group = Group::get()->filter(array("Code" => self::$register_group_code))->first();
     if ($group) {
         $member->Groups()->add($group);
     }
     if ($newMember) {
         $member->logIn();
         $link = ContentController::join_links($this->Link(), 'welcome');
     } else {
         $link = ContentController::join_links($this->Link(), 'thanks');
     }
     if (!isset($_REQUEST["BackURL"]) && Session::get('BackURL')) {
         $_REQUEST["BackURL"] = Session::get('BackURL');
     }
     if (isset($_REQUEST["BackURL"])) {
         $link = urldecode($_REQUEST["BackURL"]);
         Session::set('BackURL', '');
     }
     if ($link) {
         return $this->redirect($link);
     }
     return array();
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-userpage,代码行数:75,代码来源:RegisterAndEditDetailsPage.php


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