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;
 }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
 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($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);
 }
 /**
  * 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"));
 }
 /**
  * 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;
 }
 /**
  * @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');
 }
 /**
  * @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');
 }
Exemple #10
0
 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;
 }
Exemple #12
0
 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 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();
 }
 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'));
 }
 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;
 }
Exemple #16
0
 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);
 }
 /**
  * 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;
 }
 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 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;
 }
 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;
 }
Exemple #22
0
 public function createFields()
 {
     $order = $this->order;
     $member = $this->customer;
     //Personal details fields
     if (!$member->ID || $member->Password == '') {
         $link = $this->controller->Link();
         $note = _t('CheckoutPage.NOTE', 'NOTE:');
         $passwd = _t('CheckoutPage.PLEASE_CHOOSE_PASSWORD', 'Please choose a password, so you can login and check your order history in the future.');
         $mber = sprintf(_t('CheckoutPage.ALREADY_MEMBER', 'If you are already a member please %s log in. %s'), "<a href=\"Security/login?BackURL={$link}\">", '</a>');
         $personalFields = CompositeField::create(new HeaderField(_t('CheckoutPage.ACCOUNT', "Account"), 3), new CompositeField(EmailField::create('Email', _t('CheckoutPage.EMAIL', 'Email'))->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_EMAIL_ADDRESS', "Please enter your email address."))), new CompositeField(new FieldGroup(new ConfirmedPasswordField('Password', _t('CheckoutPage.PASSWORD', "Password")))), new CompositeField(new LiteralField('AccountInfo', "\r\n\t\t\t\t\t\t<p class=\"alert alert-info\">\r\n\t\t\t\t\t\t\t<strong class=\"alert-heading\">{$note}</strong>\r\n\t\t\t\t\t\t\t{$passwd} <br /><br />\r\n\t\t\t\t\t\t\t{$mber}\r\n\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t")))->setID('PersonalDetails')->setName('PersonaDetails');
     }
     //Order item fields
     $items = $order->Items();
     $itemFields = CompositeField::create()->setName('ItemsFields');
     if ($items) {
         foreach ($items as $item) {
             $itemFields->push(new OrderForm_ItemField($item));
         }
     }
     //Order modifications fields
     $subTotalModsFields = CompositeField::create()->setName('SubTotalModificationsFields');
     $subTotalMods = $order->SubTotalModifications();
     if ($subTotalMods && $subTotalMods->exists()) {
         foreach ($subTotalMods as $modification) {
             $modFields = $modification->getFormFields();
             foreach ($modFields as $field) {
                 $subTotalModsFields->push($field);
             }
         }
     }
     $totalModsFields = CompositeField::create()->setName('TotalModificationsFields');
     $totalMods = $order->TotalModifications();
     if ($totalMods && $totalMods->exists()) {
         foreach ($totalMods as $modification) {
             $modFields = $modification->getFormFields();
             foreach ($modFields as $field) {
                 $totalModsFields->push($field);
             }
         }
     }
     //Payment fields
     $supported_methods = PaymentProcessor::get_supported_methods();
     $source = array();
     foreach ($supported_methods as $methodName) {
         $methodConfig = PaymentFactory::get_factory_config($methodName);
         $source[$methodName] = $methodConfig['title'];
     }
     $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields');
     $fields = FieldList::create($itemFields, $subTotalModsFields, $totalModsFields, $notesFields = CompositeField::create(TextareaField::create('Notes', _t('CheckoutPage.NOTES_ABOUT_ORDER', "Notes about this order")))->setName('NotesFields'), $paymentFields);
     if (isset($personalFields)) {
         $fields->push($personalFields);
     }
     $this->extend('updateFields', $fields);
     $fields->setForm($this);
     return $fields;
 }
Exemple #23
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', UploadField::create('Photo'), 'Content');
     $fields->addFieldToTab('Root.Main', UploadField::create('PDF'), 'Content');
     $fields->addFieldToTab('Root.Main', PhoneNumberField::create('Phone'), 'Content');
     $fields->addFieldToTab('Root.Main', EmailField::create('Email'), 'Content');
     $fields->addFieldToTab('Root.Main', DropdownField::create('RoleID', 'Role', Role::get()->map('ID', 'Title'))->setEmptyString('(Select)'), 'Content');
     $fields->addFieldToTab('Root.Main', DropdownField::create('DepartmentID', 'Department', Department::get()->map('ID', 'Title'))->setEmptyString('(Select)'), 'Content');
     return $fields;
 }
 public function ContactForm()
 {
     $fields = new FieldList(TextField::create('Name')->setValue('Name')->addExtraClass('full'), EmailField::create('Email')->setValue('Email')->addExtraClass('full'), TextareaField::create('Message')->setValue('Message'), TextField::create('Spam')->setTitle('Is fire hot or cold?')->setValue('Is fire hot or cold?')->addExtraClass('full'));
     $actions = new FieldList(new FormAction('SendContactForm', 'Send'));
     $requiredFields = array('Name', 'Spam', 'Email', 'Message');
     $validator = new RequiredFields($requiredFields);
     foreach ($requiredFields as $fieldName) {
         $fields->fieldByName($fieldName)->addExtraClass("required");
     }
     return new Form($this, 'ContactForm', $fields, $actions, $validator);
 }
 public function UnsubscribeRequestForm()
 {
     $fields = new FieldList(EmailField::create('email', _t("Newsletter.UnsubscribeEmail", "Your subscription email address")));
     $actions = new FieldList(FormAction::create('sendLink', _t('Newsletter.SendUnsubscribeLink', 'Send unsubscribe link'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.RESET', 'Reset')));
     $unsubscribeController = new UnsubscribeController();
     $form = NewsletterContentControllerExtension::getUnsubscribeFormObject($this, $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction(Controller::join_links(Director::absoluteBaseURL(), $unsubscribeController->relativeLink('sendUnsubscribeLink')));
     $form->addExtraClass('cms-search-form');
     return $form;
 }
 public function ContactForm()
 {
     $FieldList = FieldList::create(array($name = TextField::create('Name', 'Your name'), $mail = EmailField::create('Email', 'Your email address'), $subj = TextField::create('Subject', 'Subject'), $rece = DropdownField::create('Receiver', 'Who to contact', Contact::getReceivers()), LiteralField::create('', '<div class="clearfix"></div>'), $area = TextareaField::create('Content', 'Message')));
     $Action = FieldList::create($btn = FormAction::create('HandleForm', 'Submit'));
     $btn->addExtraClass('button-green-full');
     $Required = RequiredFields::create(array('Name', 'Email', 'Receiver', 'Subject', 'Content'));
     /** @var Form $Form */
     $Form = Form::create($this, 'ContactForm', $FieldList, $Action, $Required);
     $Form->flashMessage = Session::get('ThanksMessage');
     return $Form;
 }
 public function __construct($controller, $name = "Users_EditAccountForm")
 {
     $fields = new FieldList(HiddenField::create("ID"), TextField::create("FirstName", _t('Member.FIRSTNAME', "First Name")), TextField::create("Surname", _t('Member.SURNAME', "Surname")), EmailField::create("Email", _t("Member.EMAIL", "Email")));
     $this->extend("updateFormFields", $fields);
     $cancel_url = Controller::join_links($controller->Link());
     $actions = new FieldList(LiteralField::create("cancelLink", '<a class="btn btn-red" href="' . $cancel_url . '">' . _t("Users.CANCEL", "Cancel") . '</a>'), FormAction::create("doUpdate", _t("CMSMain.SAVE", "Save"))->addExtraClass("btn")->addExtraClass("btn-green"));
     $this->extend("updateFormActions", $actions);
     $required = new RequiredFields(array("FirstName", "Surname", "Email"));
     $this->extend("updateRequiredFields", $required);
     parent::__construct($controller, $name, $fields, $actions, $required);
     $this->extend("updateForm", $this);
 }
Exemple #28
0
 public function getFormField()
 {
     $field = EmailField::create($this->Name, $this->Title);
     if ($this->Required) {
         // Required and Email validation can conflict so add the Required validation messages
         // as input attributes
         $errorMessage = $this->getErrorMessage()->HTML();
         $field->setAttribute('data-rule-required', 'true');
         $field->setAttribute('data-msg-required', $errorMessage);
     }
     return $field;
 }
Exemple #29
0
 public function updateCMSFields(FieldList $f)
 {
     $f->addFieldToTab('Root.Main', TextField::create('Phone', 'Phone'));
     $f->addFieldToTab('Root.Main', TextField::create('Fax', 'Fax'));
     $f->addFieldToTab('Root.Main', TextField::create('Address', 'Address'));
     $f->addFieldToTab('Root.Main', TextField::create('City', 'City'));
     $f->addFieldToTab('Root.Main', TextField::create('Province', 'Province'));
     $f->addFieldToTab('Root.Main', TextField::create('Postal', 'Postal'));
     $f->addFieldToTab('Root.Main', EmailField::create('Email', 'Email'));
     $f->removeFieldFromTab('Root.Main', 'Theme');
     return $f;
 }
 function ContactForm()
 {
     // Create fields
     $fields = new FieldList(TextField::create('Name')->setTitle(_t('ContactPage.NAMEINPUT', "Name <em>*</em>")), TextField::create("Cellphone")->setTitle(_t('ContactPage.CELLPHONE', "Cellphone")), EmailField::create("Email")->setTitle(_t('ContactPage.EMAIL', "Email address"))->setAttribute('type', 'email'), TextareaField::create("Question")->setTitle(_t('ContactPage.QUESTION', "Question <em>*</em>")));
     $this->extend('updateContactForm', $fields);
     // Create action
     $send = new FormAction('SendContactForm', _t('ContactPage.SEND', "Send"));
     $send->addExtraClass("success btn");
     $actions = new FieldList($send);
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Question');
     return new Form($this, 'ContactForm', $fields, $actions, $validator);
 }