本文整理汇总了PHP中EmailField::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailField::setAttribute方法的具体用法?PHP EmailField::setAttribute怎么用?PHP EmailField::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailField
的用法示例。
在下文中一共展示了EmailField::setAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: ContactForm
function ContactForm()
{
// Set up the fields
$nameField = new TextField('Name', 'Name');
$nameField->setAttribute('placeholder', 'Name');
$emailField = new EmailField('Email', 'Email');
$emailField->setAttribute('placeholder', 'Email');
$messageField = new TextareaField('Message', 'Message');
$messageField->setAttribute('placeholder', 'Message');
// Add the fields
$fields = new FieldList($nameField, $emailField, $messageField);
// Create action
$actions = new FieldList(new FormAction('SendContactForm', 'Send Message'));
// Create Validators
$validator = new RequiredFields('Name', 'Email', 'Message');
// Set up the form
$form = new Form($this, 'ContactForm', $fields, $actions, $validator);
$form->setTemplate('ContactForm');
return $form;
}
示例4: RegistrationForm
/**
* @return static
*/
function RegistrationForm()
{
// Email
$email = new EmailField('Email');
$email->setAttribute('placeholder', _t('RegistrationPage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
// Password Conformation
$password = new PasswordField('Password');
$password->setAttribute('placeholder', _t('RegistrationPage.PasswordPlaceholder', 'Enter your password'))->setCustomValidationMessage(_t('RegistrationPage.PasswordValidationText', 'Your passwords do not match'), 'validation')->setAttribute('required', 'required')->addExtraClass('form-control');
// Generate the fields
$fields = new FieldList($email, $password);
// Submit Button
$action = new FormAction('Register', 'Register');
$action->addExtraClass('btn btn-primary btn-lg');
$actions = new FieldList($action);
$validator = new RequiredFields('Email', 'Password');
$form = Form::create($this, 'RegistrationForm', $fields, $actions, $validator);
if ($formData = Session::get('FormInfo.Form_RegistrationForm.data')) {
$form->loadDataFrom($formData);
}
return $form;
}
示例5: ContactForm
/**
* @return static
*/
public function ContactForm()
{
/* -----------------------------------------
* Scaffolding
------------------------------------------*/
$row = new LiteralField('', '<div class="row">');
$column = new LiteralField('', '<div class="col-xs-12 col-sm-6">');
$close = new LiteralField('', '</div>');
/* -----------------------------------------
* Fields
------------------------------------------*/
$firstName = new TextField('FirstName', 'First Name');
$firstName->setAttribute('required', 'required')->addExtraClass('form-control');
$lastName = new TextField('LastName', 'Last Name');
$lastName->setAttribute('required', 'required')->addExtraClass('form-control');
$email = new EmailField('Email', 'Email Address');
$email->setAttribute('required', 'required')->addExtraClass('form-control');
$phone = new TextField('Phone', 'Phone Number (optional)');
$phone->addExtraClass('form-control');
$message = new TextareaField('Message', 'Message');
$message->setAttribute('placeholder', _t('ContactPage.MessagePlaceholder', 'Enter your message'))->setAttribute('required', 'required')->addExtraClass('form-control');
$question = new TextField('Question', '3 + 7 = ?');
$question->setAttribute('required', 'required')->addExtraClass('form-control');
$fields = new FieldList($row, $column, $firstName, $close, $column, $lastName, $close, $close, $row, $column, $email, $close, $column, $phone, $close, $close, $message, $question);
$action = new FormAction('SendContactForm', _t('ContactPage.SubmitText', 'Submit'));
$action->addExtraClass('btn btn-primary btn-lg');
$actions = new FieldList($action);
$validator = new RequiredFields('FirstName', 'LastName', 'Email', 'Message');
$form = Form::create($this, 'ContactForm', $fields, $actions, $validator);
if ($formData = Session::get('FormInfo.Form_ContactForm.data')) {
$form->loadDataFrom($formData);
}
return $form;
}
示例6: getCreditCardFields
/**
* Create form fields to represent all of the properties on the {@link Omnipay\Common\CreditCard} object.
* The form fields are split up into relevent sections to help with adding/removing fields as needed.
*
* @return FieldList
*/
protected function getCreditCardFields()
{
$fields = new FieldList();
$tabindex = 1;
// Create personal detail fields
$firstNameTextField = new TextField('FirstName', _t('OmnipayableForm.FIRSTNAME', 'First name'));
$firstNameTextField->setAttribute('tabindex', $tabindex++);
$lastNameTextField = new TextField('LastName', _t('OmnipayableForm.LASTNAME', 'Last name'));
$lastNameTextField->setAttribute('tabindex', $tabindex++);
$companyTextField = new TextField('Company', _t('OmnipayableForm.COMPANY', 'Company'));
$companyTextField->setAttribute('tabindex', $tabindex++);
$emailEmailField = new EmailField('Email', _t('OmnipayableForm.EMAIL', 'Email'));
$emailEmailField->setAttribute('tabindex', $tabindex++);
// Create personal details group
$personalFieldGroup = new FieldGroup();
$personalFieldGroup->setName('PersonalDetails');
$personalFieldGroup->setTitle(_t('OmnipayableForm.PERSONALDETAILS', 'Personal Detials'));
// Add basic fields to personal details group
$personalFieldGroup->push($firstNameTextField);
$personalFieldGroup->push($lastNameTextField);
$personalFieldGroup->push($companyTextField);
$personalFieldGroup->push($emailEmailField);
// Add personal details group to fields
$fields->push($personalFieldGroup);
// Create credit card detail fields
$numberCreditCardField = new CreditCardField('Number', _t('OmnipayableForm.NUMBER', 'Card number'));
$numberCreditCardField->setAttribute('tabindex', $tabindex++);
$cvvTextField = new TextField('Cvv', _t('OmnipayableForm.CVV', 'Security number'));
$cvvTextField->setAttribute('tabindex', $tabindex += 3);
$expiryMonthDropdownField = new DropdownField('ExpiryMonth', _t('OmnipayableForm.EXPIRYMONTH', 'Expiry month'), $this->getMonths());
$expiryMonthDropdownField->setAttribute('tabindex', $tabindex++);
$expiryMonthDropdownField->setHasEmptyDefault(true);
$expiryYearDropdownField = new DropdownField('ExpiryYear', _t('OmnipayableForm.EXPIRYYEAR', 'Expiry year'), $this->getYears(20));
$expiryYearDropdownField->setAttribute('tabindex', $tabindex++);
$expiryYearDropdownField->setHasEmptyDefault(true);
$startMonthDropdownField = new DropdownField('StartMonth', _t('OmnipayableForm.STARTMONTH', 'Start month'), $this->getMonths());
$startMonthDropdownField->setAttribute('tabindex', $tabindex++);
$startMonthDropdownField->setHasEmptyDefault(true);
$startYearDropdownField = new DropdownField('StartYear', _t('OmnipayableForm.STARTYEAR', 'Start year'), $this->getYears(-20));
$startYearDropdownField->setAttribute('tabindex', $tabindex++);
$startYearDropdownField->setHasEmptyDefault(true);
$issueNumberTextField = new TextField('IssueNumber', _t('OmnipayableForm.ISSUENUMBER', 'Issue number'));
$issueNumberTextField->setAttribute('tabindex', $tabindex++);
$typeDropdownField = new DropdownField('Type', _t('OmnipayableForm.TYPE', 'Card type'), $this->getCreditCardTypes());
$typeDropdownField->setAttribute('tabindex', $tabindex++);
$typeDropdownField->setHasEmptyDefault(true);
$expiryDateFieldGroup = new FieldGroup();
$expiryDateFieldGroup->push($expiryMonthDropdownField);
$expiryDateFieldGroup->push($expiryYearDropdownField);
$startDateFieldGroup = new FieldGroup();
$startDateFieldGroup->push($startMonthDropdownField);
$startDateFieldGroup->push($startYearDropdownField);
// Create credit card details group
$creditCardFieldGroup = new FieldGroup();
$creditCardFieldGroup->setName('CardDetails');
$creditCardFieldGroup->setTitle(_t('OmnipayableForm.CREDITCARDDETAILS', 'Card Detials'));
// Add credit card fields to credit card details group
$creditCardFieldGroup->push($numberCreditCardField);
$creditCardFieldGroup->push($cvvTextField);
$creditCardFieldGroup->push($expiryDateFieldGroup);
$creditCardFieldGroup->push($startDateFieldGroup);
$creditCardFieldGroup->push($issueNumberTextField);
$creditCardFieldGroup->push($typeDropdownField);
// Add credit card details group to fields
$fields->push($creditCardFieldGroup);
// Create billing address fields
$billingAddress1TextField = new TextField('BillingAddress1', _t('OmnipayableForm.BILLINGADDRESS1', 'Address 1'));
$billingAddress1TextField->setAttribute('tabindex', $tabindex++);
$billingAddress2TextField = new TextField('BillingAddress2', _t('OmnipayableForm.BILLINGADDRESS2', 'Address 2'));
$billingAddress2TextField->setAttribute('tabindex', $tabindex++);
$billingCity = new TextField('BillingCity', _t('OmnipayableForm.BILLINGCITY', 'City'));
$billingCity->setAttribute('tabindex', $tabindex++);
$billingPostcode = new TextField('BillingPostcode', _t('OmnipayableForm.BILLINGPOSTCODE', 'Postcode'));
$billingPostcode->setAttribute('tabindex', $tabindex++);
$billingState = new TextField('BillingState', _t('OmnipayableForm.BILLINGSTATE', 'State'));
$billingState->setAttribute('tabindex', $tabindex++);
$billingCountry = new CountryDropdownField('BillingCountry', _t('OmnipayableForm.BILLINGCOUNTRY', 'Country'));
$billingCountry->setAttribute('tabindex', $tabindex++);
$billingPhone = new PhoneNumberField('BillingPhone', _t('OmnipayableForm.BILLINGPHONE', 'Phone'));
$billingPhone->setAttribute('tabindex', $tabindex++);
// Create billing details group
$billingFieldGroup = new FieldGroup();
$billingFieldGroup->setName('BillingAddress');
$billingFieldGroup->setTitle(_t('OmnipayableForm.BILLING', 'Billing Address'));
// Add billiing fields to billing group
$billingFieldGroup->push($billingAddress1TextField);
$billingFieldGroup->push($billingAddress2TextField);
$billingFieldGroup->push($billingCity);
$billingFieldGroup->push($billingPostcode);
$billingFieldGroup->push($billingState);
$billingFieldGroup->push($billingCountry);
$billingFieldGroup->push($billingPhone);
// Add billing details group to fields
$fields->push($billingFieldGroup);
//.........这里部分代码省略.........