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; }
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; }
/** * 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; }
/** * @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; }
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()); }
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); }
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); }
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); } }
/** * @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'); }
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); }
/** * @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'); }
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; }
/** * 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; }
public function __construct($name, $title = null, $value = "", $extraAttributes = null, $maxLength = null, $form = null) { if (is_array($extraAttributes)) { $this->extraAttributes = $extraAttributes; } parent::__construct($name, $title, $value, $maxLength, $form); }
/** * 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'); }
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")); }
public function __construct($controller, $name) { $member = Member::currentUser(); $requiredFields = null; if ($member && $member->exists()) { $fields = new FieldList(); $fields->add(new HeaderField('AddressHeader', _t('Addressable.ADDRESSHEADER', 'Avatar / Description'))); $uploadField = new UploadField('Avatar', 'Select avatar'); $uploadField->setCanAttachExisting(false); $comment = new TextareaField('Description', 'Description*'); $email = EmailField::create('Email', _t('CheckoutField.EMAIL', 'Email')); $fields->add($uploadField); $fields->add($comment); $fields->add($email); $requiredFields = $member->getValidator(); $requiredFields->addRequiredField('Avatar', 'Description', 'Email'); } else { $fields = new FieldList(); } if (get_class($controller) == 'ChefAccountPage_Controller') { $actions = new FieldList(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes'))); } 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('updateChefAccountForm', $fields, $actions, $requiredFields); } }
public function __construct($controller, $name, $fields = null, $actions = null) { $fields = new FieldList($Nickname = TextField::create('Nickname')->setTitle(_t('Member.NICKNAME', 'Member.NICKNAME')), $Type = OptionsetField::create('Type')->setTitle(_t('Member.TYPE', 'Member.TYPE'))->setSource(array("refugee" => _t('Member.TYPEREFUGEESIGNUP', 'Member.TYPEREFUGEESIGNUP'), "hostel" => _t('Member.TYPEHOSTELSIGNUP', 'Member.TYPEHOSTELSIGNUP'), "donator" => _t('Member.TYPEDONATORSIGNUP', 'Member.TYPEDONATORSIGNUP'))), $Location = BootstrapGeoLocationField::create('Location')->setTitle(_t('Member.LOCATION', 'Member.LOCATION')), $Email = EmailField::create('Email')->setTitle(_t('Member.EMAIL', 'Member.EMAIL')), PasswordField::create('Password')->setTitle(_t('Member.PASSWORD', 'Member.PASSWORD')), LiteralField::create('Accept_TOS', _t('SignupForm.CONFIRMTOS', 'SignupForm.CONFIRMTOS'))); $Type->setRightTitle(_t('Member.TYPEDESCRIPTION', 'Member.TYPEDESCRIPTION')); $Location->setRightTitle(_t('Member.LOCATIONDESCRIPTION', 'Member.LOCATIONDESCRIPTION')); $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doSignup')->setTitle(_t('SignupForm.BUTTONSIGNUP', 'SignupForm.BUTTONSIGNUP'))); parent::__construct($controller, $name, $fields, $actions, new RequiredUniqueFields($required = array("Nickname", "Type", "Location", "Email", "Password"), $unique = array("Email" => _t('SignupForm.EMAILEXISTS', 'SignupForm.EMAILEXISTS')), $objectClass = 'Member')); }
public function getCMSFields() { $this->beforeUpdateCMSFields(function ($fields) { $fields->addFieldsToTab('Root.Main', array(Textfield::create('ContactName', 'Name'), TextField::create('Phone', 'Phone'), TextField::create('Mobile', 'Mobile'), TextField::create('Fax', 'Fax'), EmailField::create('Email', 'Email'), $website = TextField::create('Website', 'Website'))); $website->setRightTitle('e.g ' . Director::absoluteBaseURL()); }); return parent::getCMSFields(); }
function TypoForm() { $array = array('green', 'yellow', 'blue', 'pink', 'orange'); $form = new Form($this, 'TestForm', $fields = FieldList::create(HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), TextField::create('TextField1', 'Text Field Example 1'), TextField::create('TextField2', 'Text Field Example 2'), TextField::create('TextField3', 'Text Field Example 3'), TextField::create('TextField4', ''), HeaderField::create('HeaderField2b', 'Field with right title', 2), $textAreaField = new TextareaField('TextareaField', 'Textarea Field'), EmailField::create('EmailField', 'Email address'), HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), OptionsetField::create('OptionSF', 'Optionset Field', $array), CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), CountryDropdownField::create('CountryDropdownField', 'Countries'), CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), HeaderField::create('HeaderField3', 'Other Fields', 3), NumericField::create('NumericField', 'Numeric Field '), DateField::create('DateField', 'Date Field'), DateField::create('DateTimeField', 'Date and Time Field'), CheckboxField::create('CheckboxField', 'Checkbox Field')), $actions = FieldList::create(FormAction::create('submit', 'Submit Button')), $requiredFields = RequiredFields::create('TextField1', 'TextField2', 'TextField3', 'ErrorField1', 'ErrorField2', 'EmailField', 'TextField3', 'RightTitleField', 'CheckboxField', 'CheckboxSetField')); $textAreaField->setColumns(45); $form->setMessage('warning message', 'warning'); return $form; }
public function ApplicationForm() { $fields = FieldList::create(TextField::create('Name', 'Full name'), EmailField::create('Email', 'Email address'), PhoneNumberField::create('Phone', 'Contact Phone number'), DropdownField::create('JobID', 'Which job are you applying for?', $this->AvailableJobs()->map('ID', 'Title'))->setEmptyString('(Select)'), TextareaField::create('Application', 'Enter your experience and skills')); $actions = FieldList::create(FormAction::create('processApplication', 'Apply')); $validator = RequiredFields::create(array('Name', 'Email', 'Phone', 'JobID', 'Application')); $form = Form::create($this, 'ApplicationForm', $fields, $actions, $validator); return $form; }
public function CommentForm() { $form = Form::create($this, __FUNCTION__, FieldList::create(TextField::create('Name', '')->setAttribute('placeholder', 'Name*')->addExtraClass('form-control'), EmailField::create('Email', '')->setAttribute('placeholder', 'Email*')->addExtraClass('form-control'), TextareaField::create('Comment', '')->setAttribute('placeholder', 'Comment*')->addExtraClass('form-control')), FieldList::create(FormAction::create('handleComment', 'Post Comment')->setUseButtonTag(true)->addExtraClass('btn btn-default-color btn-lg')), RequiredFields::create('Name', 'Email', 'Comment')); $form->addExtraClass('form-style'); $data = Session::get("FormData.{$form->getName()}.data"); //using the tirnary operator if $data exist... return $data ? $form->loadDataFrom($data) : $form; }
public function PersonalRegisterForm() { $fields = FieldList::create(array(EmailField::create('Email', '电子邮件'), ConfirmedPasswordField::create('Password', '密码'), TextField::create('FullName', '姓名'), TextField::create('IDCard', '身份证号码'), TextField::create('Phone', '联系电话'), DropdownField::create('OrganizationID', '所属单位名称', Organization::get()->map('ID', 'company_name'))->setEmptyString('请选择'))); $actions = FieldList::create(array(FormAction::create('doRegisterPersonal', '提交'))); $required = RequiredFields::create(array('Email', 'Password', 'FullName', 'IDCard', 'Phone', 'OrganizationID')); $form = new Form($this, __FUNCTION__, $fields, $actions, $required); return $form; }
public function Form() { //Define Text Fields Make Contact Form $fields = new FieldList(TextField::create('Name')->setTitle('Your Name'), EmailField::create('Email')->setTitle('Your Email'), TextareaField::create('Message')->setTitle('Write Us A Message')); $actions = new FieldList(new FormAction('submit', 'Submit')); // Validate $validator = new RequiredFields('Name', 'Message'); return new Form($this, 'Form', $fields, $actions, $validator); }
public function __construct($controller, $name) { $fields = new FieldList(TextField::create("Name"), EmailField::create("Email")->setAttribute('type', 'email'), TextareaField::create("Company", "Message")->setAttribute('autocomplete', 'no'), TextareaField::create("EmailMessage", "Company")->addExtraClass("honeypot")->setAttribute('autocomplete', 'no')); if (!class_exists('FormSpamProtectionExtension')) { $fields->insertAfter(HiddenField::create("TimeLog", '', time()), 'EmailMessage'); } $actions = new FieldList(FormAction::create("doSubmit")->setTitle("Submit")->addExtraClass('button')->setUseButtonTag(true)); parent::__construct($controller, $name, $fields, $actions); }
public function ContactForm() { $fields = new FieldList(TextField::create('Name', 'Name*')->setAttribute('placeholder', 'Your Name'), EmailField::create('Email', 'Email*')->setAttribute('placeholder', 'Your Email'), TextField::create('Phone', 'Phone')->setAttribute('placeholder', '555-555-5555'), TextField::create('Required', 'Leave this field blank', ''), TextareaField::create('Comments', 'Comments*')->setAttribute('placeholder', 'Comments')); $actions = new FieldList(FormAction::create("doSubmitForm", 'Send')); $required = new RequiredFields('Name', 'Email', 'Comments'); $form = new Form($this, 'ContactForm', $fields, $actions, $required); $form->setFormMethod('POST', true); return $form; }
public function CommentForm() { $form = Form::create($this, __FUNCTION__, FieldList::create(TextField::create('Name', ''), EmailField::create('Email', ''), TextareaField::create('Comment', '')), FieldList::create(FormAction::create('handleComment', 'Post Comment')->setUseButtonTag(true)->addExtraClass('btn btn-default-color btn-lg')), RequiredFields::create('Name', 'Email', 'Comment'))->addExtraClass('form-style'); foreach ($form->Fields() as $field) { $field->addExtraClass('form-control')->setAttribute('placeholder', $field->getName() . '*'); } $data = Session::get("FormData.{$form->getName()}.data"); return $data ? $form->loadDataFrom($data) : $form; }
public function getCMSFields() { $fields = FieldList::create(new TabSet($name = 'Root', new Tab($title = 'Main', HeaderField::create('ContactHD', 'Contact Information'), TextField::create('Title', 'Name'), TextField::create('Phone'), EmailField::create('Email', 'Email'), TextField::create('Website')->setAttribute('placeholder', 'http://'), DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))->setEmptyString('-- select --'), CheckboxField::create('ShowInLocator', 'Show in results')->setDescription('Location will be included in results list'), CheckboxField::create('Featured')->setDescription('Location will show at/near the top of the results list')))); // allow to be extended via DataExtension $this->extend('updateCMSFields', $fields); // override Suburb field name $fields->dataFieldByName('Suburb')->setTitle('City'); return $fields; }
function testFieldHasExtraClass() { /* TextField has an extra class name and is in the HTML the field returns */ $textField = new TextField('Name'); $textField->addExtraClass('thisIsMyClassNameForTheFormField'); preg_match('/thisIsMyClassNameForTheFormField/', $textField->Field(), $matches); $this->assertTrue($matches[0] == 'thisIsMyClassNameForTheFormField'); /* EmailField has an extra class name and is in the HTML the field returns */ $emailField = new EmailField('Email'); $emailField->addExtraClass('thisIsMyExtraClassForEmailField'); preg_match('/thisIsMyExtraClassForEmailField/', $emailField->Field(), $matches); $this->assertTrue($matches[0] == 'thisIsMyExtraClassForEmailField'); /* OptionsetField has an extra class name and is in the HTML the field returns */ $optionsetField = new OptionsetField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)'); $optionsetField->addExtraClass('thisIsMyExtraClassForOptionsetField'); preg_match('/thisIsMyExtraClassForOptionsetField/', $optionsetField->Field(), $matches); $this->assertTrue($matches[0] == 'thisIsMyExtraClassForOptionsetField'); }
/** * Setup the fields for the frontend * @param type $params * @return FieldList $fields the default FieldList */ public function getFrontEndFields($params = null) { $fields = parent::getFrontEndFields($params); $fields->removeByName(array('MD5Email', 'AkismetMarked', 'Visible', 'ShowGravatar', 'News')); $fields->replaceField('Email', EmailField::create('Email', $this->fieldLabel('Email'))); $fields->replaceField('Comment', TextAreaField::create('Comment', $this->fieldLabel('Comment'))); $fields->fieldByName('Comment')->setColumns(20)->setRows(10); return $fields; }