本文整理汇总了PHP中EmailField类的典型用法代码示例。如果您正苦于以下问题:PHP EmailField类的具体用法?PHP EmailField怎么用?PHP EmailField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EmailField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createForgotPassForm
public function _createForgotPassForm()
{
$form = new Form();
$form->action = "/forgotpass";
$form->add(EmailField::name('email')->label('Email')->help('What is your email address?')->required(true));
return $form;
}
示例2: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
// Contact Form settings
$recipient_field = new EmailField('DefaultRecipient', 'Email recipient');
$recipient_field->setDescription('Default email address to send submissions to.');
$subject_field = new TextField('Subject', 'Email subject');
$subject_field->setDescription('Subject for the email.');
$default_from_field = new EmailField('DefaultFrom', 'Email from');
$default_from_field->setDescription('Default from email address.');
$fields->addFieldToTab('Root.ContactForm.Settings', $recipient_field);
$fields->addFieldToTab('Root.ContactForm.Settings', $subject_field);
$fields->addFieldToTab('Root.ContactForm.Settings', $default_from_field);
// Contact Form fields
$conf = GridFieldConfig_RelationEditor::create(10);
$conf->addComponent(new GridFieldSortableRows('SortOrder'));
$data_columns = $conf->getComponentByType('GridFieldDataColumns');
$data_columns->setDisplayFields(array('Name' => 'Name', 'Type' => 'Type', 'requiredText' => 'Required'));
$contact_form_fields = new GridField('Fields', 'Field', $this->ContactFields(), $conf);
$fields->addFieldToTab('Root.ContactForm.Fields', $contact_form_fields);
// Recipient map
$contact_fields = array();
foreach ($this->ContactFields() as $contact_field) {
$contact_fields[$contact_field->Name] = $contact_field->Name;
}
$recipient_map_field_field = new DropdownField('RecipientMapField', 'Recipient Map Field', $contact_fields);
$recipient_map_field_field->setDescription('Field used to map recipients.');
$recipient_map_field = new TextareaField('RecipientMap', 'Recipient Map');
$recipient_map_field->setDescription('Map field values to an email address (format: value:email address) one per line.');
$fields->addFieldToTab('Root.ContactForm.RecipientMap', $recipient_map_field_field);
$fields->addFieldToTab('Root.ContactForm.RecipientMap', $recipient_map_field);
return $fields;
}
示例3: 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;
}
示例4: EditProfileForm
/**
* @return Form|SS_HTTPResponse
*/
public function EditProfileForm()
{
if (!Member::currentUser()) {
$this->setFlash(_t('EditProfilePage.LoginWarning', 'Please login to edit your profile'), 'warning');
return $this->redirect(Director::absoluteBaseURL());
}
$firstName = new TextField('FirstName');
$firstName->setAttribute('placeholder', _t('EditProfilePage.FirstNamePlaceholder', 'Enter your first name'))->setAttribute('required', 'required')->addExtraClass('form-control');
$surname = new TextField('Surname');
$surname->setAttribute('placeholder', _t('EditProfilePage.SurnamePlaceholder', 'Enter your surname'))->setAttribute('required', 'required')->addExtraClass('form-control');
$email = new EmailField('Email');
$email->setAttribute('placeholder', _t('EditProfilePage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
$jobTitle = new TextField('JobTitle');
$jobTitle->setAttribute('placeholder', _t('EditProfilePage.JobTitlePlaceholder', 'Enter your job title'))->addExtraClass('form-control');
$website = new TextField('Website');
$website->setAttribute('placeholder', _t('EditProfilePage.WebsitePlaceholder', 'Enter your website'))->addExtraClass('form-control');
$blurb = new TextareaField('Blurb');
$blurb->setAttribute('placeholder', _t('EditProfilePage.BlurbPlaceholder', 'Enter your blurb'))->addExtraClass('form-control');
$confirmPassword = new ConfirmedPasswordField('Password', _t('EditProfilePage.PasswordLabel', 'New Password'));
$confirmPassword->canBeEmpty = true;
$confirmPassword->setAttribute('placeholder', _t('EditProfilePage.PasswordPlaceholder', 'Enter your password'))->addExtraClass('form-control');
$fields = new FieldList($firstName, $surname, $email, $jobTitle, $website, $blurb, $confirmPassword);
$action = new FormAction('SaveProfile', _t('EditProfilePage.SaveProfileText', 'Update Profile'));
$action->addExtraClass('btn btn-primary btn-lg');
$actions = new FieldList($action);
// Create action
$validator = new RequiredFields('FirstName', 'Email');
//Create form
$form = new Form($this, 'EditProfileForm', $fields, $actions, $validator);
//Populate the form with the current members data
$Member = Member::currentUser();
$form->loadDataFrom($Member->data());
//Return the form
return $form;
}
示例5: testMessagesInsideNestedCompositeFields
public function testMessagesInsideNestedCompositeFields()
{
$fieldGroup = new FieldGroup(new CompositeField($textField = new TextField('TestField', 'Test Field'), $emailField = new EmailField('TestEmailField', 'Test Email Field')));
$textField->setError('Test error message', 'warning');
$emailField->setError('Test error message', 'error');
$this->assertEquals('Test error message, Test error message.', $fieldGroup->Message());
$this->assertEquals('warning. error', $fieldGroup->MessageType());
}
示例6: __construct
function __construct($controller, $name, $use_actions = true)
{
$fields = new FieldList();
//point of contact
$fields->push($point_of_contact_name = new TextField('point_of_contact_name', 'Name'));
$fields->push($point_of_contact_email = new EmailField('point_of_contact_email', 'Email'));
//main info
$fields->push($title = new TextField('title', 'Title'));
$fields->push($url = new TextField('url', 'Url'));
$fields->push(new CheckboxField('is_coa_needed', 'Is COA needed?'));
$fields->push($ddl_type = new DropdownField('job_type', 'Job Type', JobType::get()->sort("Type")->map("ID", "Type")));
$ddl_type->setEmptyString("--SELECT A JOB TYPE --");
$fields->push($description = new HtmlEditorField('description', 'Description'));
$fields->push($instructions = new HtmlEditorField('instructions', 'Instructions To Apply'));
$fields->push($expiration_date = new TextField('expiration_date', 'Expiration Date'));
$fields->push($company = new CompanyField('company', 'Company'));
$point_of_contact_name->addExtraClass('job_control');
$point_of_contact_email->addExtraClass('job_control');
$title->addExtraClass('job_control');
$url->addExtraClass('job_control');
$description->addExtraClass('job_control');
$instructions->addExtraClass('job_control');
$expiration_date->addExtraClass('job_control');
$company->addExtraClass('job_control');
//location
$ddl_locations = new DropdownField('location_type', 'Location Type', array('N/A' => 'N/A', 'Remote' => 'Remote', 'Various' => 'Add a Location'));
$ddl_locations->addExtraClass('location_type');
$ddl_locations->addExtraClass('job_control');
$fields->push($ddl_locations);
$fields->push($city = new TextField('city', 'City'));
$fields->push($state = new TextField('state', 'State'));
$fields->push($country = new CountryDropdownField('country', 'Country'));
$city->addExtraClass('physical_location');
$state->addExtraClass('physical_location');
$country->addExtraClass('physical_location');
// Guard against automated spam registrations by optionally adding a field
// that is supposed to stay blank (and is hidden from most humans).
// The label and field name are intentionally common ("username"),
// as most spam bots won't resist filling it out. The actual username field
// on the forum is called "Nickname".
$fields->push(new TextField('user_name', 'UserName'));
// Create action
$actions = new FieldList();
if ($use_actions) {
$actions->push(new FormAction('saveJobRegistrationRequest', 'Save'));
}
// Create validators
$validator = new ConditionalAndValidationRule([new HtmlPurifierRequiredValidator('title', 'instructions', 'description'), new RequiredFields('job_type', 'point_of_contact_name', 'point_of_contact_email')]);
$this->addExtraClass('job-registration-form');
$this->addExtraClass('input-form');
parent::__construct($controller, $name, $fields, $actions, $validator);
}
示例7: getFormField
public function getFormField()
{
if ($this->Required) {
// Required and Email validation can conflict so add the Required validation messages
// as input attributes
$errorMessage = $this->getErrorMessage()->HTML();
$field = new EmailField($this->Name, $this->Title);
$field->setAttribute('data-rule-required', 'true');
$field->setAttribute('data-msg-required', $errorMessage);
return $field;
}
return new EmailField($this->Name, $this->Title);
}
示例8: __construct
public function __construct($controller, $name)
{
$member = Member::currentUser();
$requiredFields = null;
if ($member && $member->exists()) {
/**
* 29-01-2015 Cambio realizado para no recoger todos los datos de Member
* ----------
* Solo pillamos datos basicos
*/
//$fields = $member->getMemberFormFields();
//$fields->removeByName('Password');
$fields = new FieldList($firstname = TextField::create('FirstName', _t('CheckoutField.FIRSTNAME', 'First Name')), $surname = TextField::create('Surname', _t('CheckoutField.SURNAME', 'Surname')), $email = EmailField::create('Email', _t('CheckoutField.EMAIL', 'Email')));
$requiredFields = $member->getValidator();
$requiredFields->addRequiredField('Surname');
} else {
$fields = new FieldList();
}
if (get_class($controller) == 'AccountPage_Controller') {
$actions = new FieldList(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')));
} else {
$actions = new FieldList(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')), new FormAction('proceed', _t('MemberForm.SAVEANDPROCEED', 'Save and proceed to checkout')));
}
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
if ($member) {
$member->Password = "";
//prevents password field from being populated with encrypted password data
$this->loadDataFrom($member);
}
if ($record = $controller->data()) {
$record->extend('updateShopAccountForm', $fields, $actions, $requiredFields);
}
}
示例9: __construct
/**
* @param Controller $controller
* @param String $name
* @param array $arguments
*/
public function __construct($controller, $name, $arguments = array())
{
/** -----------------------------------------
* Fields
* ----------------------------------------*/
/** @var EmailField $email */
$email = EmailField::create('Email', 'Email Address');
$email->addExtraClass('form-control')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
$fields = FieldList::create($email);
/** -----------------------------------------
* Actions
* ----------------------------------------*/
$actions = FieldList::create(FormAction::create('Subscribe')->setTitle('Subscribe')->addExtraClass('btn btn-primary'));
/** -----------------------------------------
* Validation
* ----------------------------------------*/
$required = RequiredFields::create('Email');
/** @var Form $form */
$form = Form::create($this, $name, $fields, $actions, $required);
if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
$form->loadDataFrom($formData);
}
parent::__construct($controller, $name, $fields, $actions, $required);
$this->setAttribute('data-parsley-validate', true);
$this->addExtraClass('form');
}
示例10: __construct
public function __construct($name, $title = null, $value = "")
{
// naming with underscores to prevent values from actually being saved somewhere
$this->fieldType = new OptionsetField("{$name}[Type]", _t('HtmlEditorField.LINKTO', 'Link to'), array('Internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'External' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'Email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'File' => _t('HtmlEditorField.LINKFILE', 'Download a file')), 'Internal');
$this->fieldLink = new CompositeField($this->internalField = WTTreeDropdownField::create("{$name}[Internal]", _t('HtmlEditorField.Internal', 'Internal'), 'SiteTree', 'ID', 'Title', true), $this->externalField = TextField::create("{$name}[External]", _t('HtmlEditorField.URL', 'URL'), 'http://'), $this->emailField = EmailField::create("{$name}[Email]", _t('HtmlEditorField.EMAIL', 'Email address')), $this->fileField = WTTreeDropdownField::create("{$name}[File]", _t('HtmlEditorField.FILE', 'File'), 'File', 'ID', 'Title', true), $this->extraField = TextField::create("{$name}[Extra]", 'Extra(optional)')->setDescription('Appended to url. Use to add sub-urls/actions or query string to the url, e.g. ?param=value'), $this->anchorField = TextField::create("{$name}[Anchor]", 'Anchor (optional)'), $this->targetBlankField = CheckboxField::create("{$name}[TargetBlank]", _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')));
if ($linkableDataObjects = WTLink::get_data_object_types()) {
if (!($objects = self::$linkable_data_objects)) {
$objects = array();
foreach ($linkableDataObjects as $className) {
$classObjects = array();
//set the format for DO value -> ClassName-ID
foreach (DataList::create($className) as $object) {
$classObjects[$className . '-' . $object->ID] = $object->Title;
}
if (!empty($classObjects)) {
$objects[singleton($className)->i18n_singular_name()] = $classObjects;
}
}
}
if (count($objects)) {
$this->fieldType->setSource(array_merge($this->fieldType->getSource(), array('DataObject' => _t('WTLinkField.LINKDATAOBJECT', 'Data Object'))));
$this->fieldLink->insertBefore("{$name}[Extra]", $this->dataObjectField = GroupedDropdownField::create("{$name}[DataObject]", _t('WTLinkField.LINKDATAOBJECT', 'Link to a Data Object'), $objects));
}
self::$linkable_data_objects = $objects;
}
$this->extraField->addExtraClass('no-hide');
$this->anchorField->addExtraClass('no-hide');
$this->targetBlankField->addExtraClass('no-hide');
parent::__construct($name, $title, $value);
}
示例11: __construct
/**
* @param Controller $controller
* @param String $name
* @param array $arguments
*/
public function __construct($controller, $name, $arguments = array())
{
/** =========================================
* @var EmailField $emailField
* @var TextField $nameField
* @var FormAction $submit
* @var Form $form
===========================================*/
/** -----------------------------------------
* Fields
* ----------------------------------------*/
$emailField = EmailField::create('Email', 'Email Address');
$emailField->addExtraClass('form-control')->setAttribute('placeholder', 'Email')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
$nameField = TextField::create('Name', 'Name');
$nameField->setAttribute('placeholder', 'Name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Name</strong>')->setCustomValidationMessage('Please enter your <strong>Name</strong>');
$fields = FieldList::create($nameField, $emailField);
/** -----------------------------------------
* Actions
* ----------------------------------------*/
$submit = FormAction::create('Subscribe');
$submit->setTitle('SIGN UP')->addExtraClass('button');
$actions = FieldList::create($submit);
/** -----------------------------------------
* Validation
* ----------------------------------------*/
$required = RequiredFields::create('Name', 'Email');
$form = Form::create($this, $name, $fields, $actions, $required);
if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
$form->loadDataFrom($formData);
}
parent::__construct($controller, $name, $fields, $actions, $required);
$this->setAttribute('data-parsley-validate', true);
$this->addExtraClass('form');
}
示例12: UpdateForm
public function UpdateForm()
{
$member = singleton('SecurityContext')->getMember();
if (!$member) {
return '';
}
// if there's a member profile page availble, use it
$filter = array();
if (class_exists('Multisites')) {
$filter = array('SiteID' => Multisites::inst()->getCurrentSiteId());
}
// use member profile page if possible
if (class_exists('MemberProfilePage') && ($profilePage = MemberProfilePage::get()->filter($filter)->first())) {
$controller = MemberProfilePage_Controller::create($profilePage);
$form = $controller->ProfileForm();
$form->addExtraClass('ajax-form');
$form->loadDataFrom($member);
return $form;
} else {
$password = new ConfirmedPasswordField('Password', $member->fieldLabel('Password'), null, null, (bool) $this->ID);
$password->setCanBeEmpty(true);
$fields = FieldList::create(TextField::create('FirstName', $member->fieldLabel('FirstName')), TextField::create('Surname', $member->fieldLabel('Surname')), EmailField::create('Email', $member->fieldLabel('Email')), $password);
$actions = FieldList::create($update = FormAction::create('updateprofile', 'Update'));
$form = Form::create($this, 'UpdateForm', $fields, $actions);
$form->loadDataFrom($member);
$this->extend('updateProfileDashletForm', $form);
return $form;
}
return;
}
示例13: getCMSFields
/**
* Returns a FieldList with which to create the main editing form.
*
* @return FieldList The fields to be displayed in the CMS.
*/
public function getCMSFields()
{
// Get the CMS fields
$fields = parent::getCMSFields();
// Update the existing fields with labels
$nameField = $fields->dataFieldByName("Title");
if ($nameField) {
$nameField->setRightTitle("Staff members name (John Smith etc)");
}
// Add the fields to the CMS
$fields->addFieldToTab("Root.Main", TextField::create("Position", _t("StaffProfilePage.PositionTitle", "Position")), "Content");
$fields->addFieldToTab("Root.Main", EmailField::create("Email", _t("StaffProfilePage.EmailTitle", "Email address")), "Content");
$fields->addFieldToTab("Root.Main", TextField::create("Phone", _t("StaffProfilePage.PhoneTitle", "Phone")), "Content");
$fields->addFieldToTab("Root.Categories", GridField::create("Categories", _t("StaffProfilePage.CategoriesTitle", "Categories"), $this->Categories(), StaffProfilePage_Category::getGridFieldConfig()));
// Add the thumbnail field
$uploadField = UploadField::create("Thumbnail", _t("StaffProfilePage.ThumbnailTitle", "Thumbnail"));
$uploadField->setFolderName('Staff');
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
$sizeMB = 0.3;
// MB
$size = $sizeMB * 1024 * 1024;
// Bytes
$uploadField->getValidator()->setAllowedMaxFileSize($size);
$fields->addFieldToTab("Root.Main", $uploadField, "Content");
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例14: __construct
/**
* RegistrationForm constructor
*
* @param Controller $controller
* @param String $name
* @param array $arguments
*/
public function __construct($controller, $name, $arguments = array())
{
/** -----------------------------------------
* Fields
* ----------------------------------------*/
/** @var TextField $firstName */
$firstName = TextField::create('FirstName');
$firstName->setAttribute('placeholder', 'Enter your first name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>First Name</strong>')->setCustomValidationMessage('Please enter your <strong>First Name</strong>');
/** @var EmailField $email */
$email = EmailField::create('Email');
$email->setAttribute('placeholder', 'Enter your email address')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
/** @var PasswordField $password */
$password = PasswordField::create('Password');
$password->setAttribute('placeholder', 'Enter your password')->setCustomValidationMessage('Please enter your <strong>Password</strong>')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Password</strong>');
$fields = FieldList::create($email, $password);
/** -----------------------------------------
* Actions
* ----------------------------------------*/
$actions = FieldList::create(FormAction::create('Register')->setTitle('Register')->addExtraClass('btn--primary'));
/** -----------------------------------------
* Validation
* ----------------------------------------*/
$required = RequiredFields::create('FirstName', 'Email', 'Password');
/** @var Form $form */
$form = Form::create($this, $name, $fields, $actions, $required);
if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
$form->loadDataFrom($formData);
}
parent::__construct($controller, $name, $fields, $actions, $required);
$this->setAttribute('data-parsley-validate', true);
$this->addExtraClass('form form--registration');
}
示例15: __construct
public function __construct($controller, $name, $fields = null, $actions = null)
{
$fields = new FieldList($Email = EmailField::create('Email')->setTitle(_t('ContactForm.EMAIL', 'ContactForm.EMAIL')), $Name = TextField::create('Name')->setTitle(_t('ContactForm.NAME', 'ContactForm.NAME')), $Message = TextareaField::create('Message')->setTitle(_t('ContactForm.MESSAGE', 'ContactForm.MESSAGE')));
$actions = new FieldList($Submit = FormAction::create('doContact')->setTitle(_t('ContactForm.BUTTONSEND', 'ContactForm.BUTTONSEND')));
$Submit->addExtraClass('btn');
parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Email", "Name", "Message"));
}