function __construct($controller, $name)
 {
     $member = Member::currentUser();
     $requiredFields = null;
     if ($member && $member->exists()) {
         $fields = $member->getEcommerceFields();
         $passwordField = new ConfirmedPasswordField('Password', _t('MemberForm.PASSWORD', 'Password'));
         if ($member->Password != '') {
             $passwordField->setCanBeEmpty(true);
         }
         //TODO:is this necessary?
         $fields->push(new LiteralField('LogoutNote', "<p class=\"message warning\">" . _t("MemberForm.LOGGEDIN", "You are currently logged in as ") . $member->FirstName . ' ' . $member->Surname . ". " . _t('MemberForm.LOGOUT', 'Click <a href="Security/logout">here</a> to log out.') . "</p>"));
         $fields->push(new HeaderField('Login Details', _t('MemberForm.LOGINDETAILS', 'Login Details'), 3));
         $fields->push($passwordField);
         $requiredFields = new ShopAccountFormValidator($member->getEcommerceRequiredFields());
     } else {
         $fields = new FieldSet();
     }
     if (get_class($controller) == 'AccountPage_Controller') {
         $actions = new FieldSet(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')));
     } else {
         $actions = new FieldSet(new FormAction('submit', _t('MemberForm.SAVE', 'Save Changes')), new FormAction('proceed', _t('MemberForm.SAVEANDPROCEED', 'Save and proceed to checkout')));
     }
     if ($record = $controller->data()) {
         $record->extend('updateShopAccountForm', $fields, $actions, $requiredFields);
     }
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     if ($member) {
         $member->Password = "";
         //prevents password field from being populated with encrypted password data
         $this->loadDataFrom($member);
     }
 }
 /**
  * @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;
 }
 function updateCMSFields(FieldList $fields)
 {
     $fields->removeFieldFromTab('Root.Members', 'Members');
     $fieldList = array('FirstName' => 'Name', 'Surname' => 'Last Name');
     $password = new ConfirmedPasswordField('Password', null, null, null, true);
     $password->setCanBeEmpty(true);
     $detailFormFields = new FieldList(new TabSet("Root", new Tab('Main', 'Main', new HeaderField('MemberDetailsHeader', "Personal Details"), new TextField("FirstName", "First Name"), new TextField("Surname", "Last Name"), new HeaderField('MemberUserDetailsHeader', "User Details"), $password, new TextField("Email", "Email"), new TextField("SecondEmail", "Second Email"), new TextField("Third Email", "Third Email"), new TextField("FoodPreference", "Food Preference"), new TextField("OtherFood", "Other Food"), new TextField("IRCHandle", "IRC Handle"), new TextField("TwitterName", "Twitter Name"), new TextField("LinkedInProfile", "LinkedIn Profile"), new TextField("JobTitle", "Job Title"), new TextField("Role", "Role"), new TextareaField("StatementOfInterest", "Statement Of Interest"), new HtmlEditorField("Bio", "Bio"))));
     // make table sortable for foundation-staff and supporting-cast
     if ($this->owner->Code == 'openstack-foundation-staff' || $this->owner->Code == 'supporting-cast') {
         $config = GridFieldConfig_RelationEditor::create(10);
         $config->getComponentByType('GridFieldDetailForm')->setFields($detailFormFields);
         $sort = new GridFieldSortableRows('SortOrder');
         $config->addComponent($sort);
         $config->removeComponentsByType('GridFieldPageCount');
         $config->removeComponentsByType('GridFieldPaginator');
         $dataColumns = $config->getComponentByType('GridFieldDataColumns');
         $dataColumns->setDisplayFields(array('SortOrder' => 'Order', 'FirstName' => 'Name', 'Surname' => 'Surname', 'Email' => 'Email'));
     } else {
         $config = GridFieldConfig_RelationEditor::create(10);
         $config->getComponentByType('GridFieldDetailForm')->setFields($detailFormFields);
     }
     $manager = new GridField('Members', 'Members', $this->owner->Members(), $config);
     $fields->addFieldToTab('Root.Members', $manager);
     $fields->push(new HiddenField("GroupEdtion", "GroupEdtion", "1"));
 }
 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;
 }
 function updateCMSFields(FieldList $fields)
 {
     $fields->removeFieldFromTab('Root.Members', 'Members');
     $fieldList = array('FirstName' => 'Name', 'Surname' => 'Last Name');
     $password = new ConfirmedPasswordField('Password', null, null, null, true);
     $password->setCanBeEmpty(true);
     $detailFormFields = new FieldList(new TabSet("Root", new Tab('Main', 'Main', new HeaderField('MemberDetailsHeader', "Personal Details"), new TextField("FirstName", "First Name"), new TextField("Surname", "Last Name"), new HeaderField('MemberUserDetailsHeader', "User Details"), $password, new TextField("Email", "Email"), new TextField("SecondEmail", "Second Email"), new TextField("Third Email", "Third Email"), new TextField("FoodPreference", "Food Preference"), new TextField("OtherFood", "Other Food"), new TextField("IRCHandle", "IRC Handle"), new TextField("TwitterName", "Twitter Name"), new TextField("LinkedInProfile", "LinkedIn Profile"), new TextField("JobTitle", "Job Title"), new TextField("Role", "Role"), new TextareaField("StatementOfInterest", "Statement Of Interest"), new HtmlEditorField("Bio", "Bio"))));
     $config = GridFieldConfig_RelationEditor::create(10);
     $config->getComponentByType('GridFieldDetailForm')->setFields($detailFormFields);
     $manager = new GridField('Members', 'Members', $this->owner->Members(), $config);
     $fields->addFieldToTab('Root.Members', $manager);
     $fields->push(new HiddenField("GroupEdtion", "GroupEdtion", "1"));
 }
Beispiel #6
0
 /**
  * Add some fields for managing Members in the CMS.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet('Root', Tab::create('Customer')));
     $password = new ConfirmedPasswordField('Password', null, null, null, true);
     $password->setCanBeEmpty(true);
     if (!$this->ID) {
         $password->showOnClick = false;
     }
     $fields->addFieldsToTab('Root.Customer', array(new TextField('FirstName'), new TextField('Surname'), new EmailField('Email'), new ConfirmedPasswordField('Password'), $password));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Beispiel #7
0
 function testSetShowOnClick()
 {
     //hide by default and display show/hide toggle button
     $field = new ConfirmedPasswordField('Test', 'Testing', 'valueA', null, true);
     $fieldHTML = $field->Field();
     $this->assertContains("showOnClickContainer", $fieldHTML, "Test class for hiding/showing the form contents is set");
     $this->assertContains("showOnClick", $fieldHTML, "Test class for hiding/showing the form contents is set");
     //show all by default
     $field = new ConfirmedPasswordField('Test', 'Testing', 'valueA', null, false);
     $fieldHTML = $field->Field();
     $this->assertNotContains("showOnClickContainer", $fieldHTML, "Test class for hiding/showing the form contents is set");
     $this->assertNotContains("showOnClick", $fieldHTML, "Test class for hiding/showing the form contents is set");
 }
 public function getPasswordField($confirmed = true)
 {
     if ($confirmed) {
         return ConfirmedPasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
     }
     return PasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
 }
 public function getPasswordField()
 {
     if ($this->confirmed) {
         //relies on fix: https://github.com/silverstripe/silverstripe-framework/pull/2757
         return ConfirmedPasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'))->setCanBeEmpty(!Checkout::membership_required());
     }
     return PasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
 }
 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;
 }
 function testSetValue()
 {
     $field = new ConfirmedPasswordField('Test', 'Testing', 'valueA');
     $this->assertEquals('valueA', $field->Value());
     $this->assertEquals('valueA', $field->children->fieldByName($field->Name() . '[_Password]')->Value());
     $this->assertEquals('valueA', $field->children->fieldByName($field->Name() . '[_ConfirmPassword]')->Value());
     $field->setValue('valueB');
     $this->assertEquals('valueB', $field->Value());
     $this->assertEquals('valueB', $field->children->fieldByName($field->Name() . '[_Password]')->Value());
     $this->assertEquals('valueB', $field->children->fieldByName($field->Name() . '[_ConfirmPassword]')->Value());
 }
 function __construct($controller, $name)
 {
     $member = Member::currentUser();
     if ($member && $member->exists()) {
         $fields = $member->getEcommerceFields();
         $passwordField = new ConfirmedPasswordField('Password', 'Password');
         if ($member->Password != '') {
             $passwordField->setCanBeEmpty(true);
         }
         $fields->push(new LiteralField('LogoutNote', "<p class=\"message good\">" . _t("MemberForm.LOGGEDIN", "You are currently logged in as ") . $member->FirstName . ' ' . $member->Surname . ". Click <a href=\"Security/logout\" title=\"Click here to log out\">here</a> to log out.</p>"));
         $fields->push(new HeaderField('Login Details', 3));
         $fields->push($passwordField);
         $requiredFields = new RequiredFields($member->getEcommerceRequiredFields());
     } else {
         $fields = new FieldSet();
     }
     $actions = new FieldSet(new FormAction('submit', 'Save Changes'), new FormAction('proceed', 'Save and proceed to checkout'));
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     if ($member) {
         $this->loadDataFrom($member);
     }
 }
 public function __construct($controller, $name)
 {
     /* Fields */
     $fields = FieldList::create(TextField::create("FirstName", "First Name"), TextField::create("Surname", "Surname"), TextField::create("CompanyName", "Company Name (optional)"), EmailField::create("Email", "Email Address"), ConfirmedPasswordField::create("Password", "Password"), TextField::create("LandlineNumber", "Landline Number"), TextField::create("MobileNumber", "Mobile Number"));
     /* Actions */
     $actions = FieldList::create(CompositeField::create(FormAction::create('createaccount', 'Create Account')));
     /* Required Fields */
     $required = new RequiredFields(array("FirstName", "Surname", "Email", "Password"));
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $actions, $required);
 }
    function __construct($controller, $name)
    {
        $member = Member::currentUser();
        if ($member && $member->exists()) {
            $fields = $member->getCleanUpMemberRoleFields();
            $passwordField = new ConfirmedPasswordField('Password', 'Password');
            if ($member->Password != '') {
                $passwordField->setCanBeEmpty(true);
            }
            $fields->push($passwordField);
            $fields->push(new LiteralField('LogoutNote', "<div class=\"clear\"></div><p class=\"message good\">" . _t("MemberForm.LOGGEDIN", "You are currently logged in as ") . $member->FirstName . ' ' . $member->Surname . ". Click <a href=\"Security/logout\" title=\"Click here to log out\">here</a> to log out.</p>"));
            //$fields->push(new HeaderField('Login Details', 3));
            $requiredFields = '';
        } else {
            $fields = new FieldSet();
        }
        Requirements::customScript('
			jQuery(document).ready(function() {
				
				jQuery("#AccountForm_MemberForm_FirstName").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#AccountForm_MemberForm_Surname").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#AccountForm_MemberForm_Address").addClass("validate[required,length[6,300]] text-input");
				jQuery("#AccountForm_MemberForm_Email").addClass("validate[required,custom[email]] text-input");
				jQuery("#AccountForm_MemberForm #Password input").addClass("validate[required,length[6,100]] text-input");
				
				jQuery("#AccountForm_MemberForm").validationEngine()
				
			});
		');
        $requiredFields = '';
        $actions = new FieldSet(new FormAction('submit', 'Save Changes'));
        parent::__construct($controller, $name, $fields, $actions, $requiredFields);
        if ($member) {
            $this->loadDataFrom($member);
        }
    }
 public function testValidation()
 {
     $field = new ConfirmedPasswordField('Test', 'Testing', array("_Password" => "abc123", "_ConfirmPassword" => "abc123"));
     $validator = new RequiredFields();
     $form = new Form($this, 'Form', new FieldList($field), new FieldList(), $validator);
     $this->assertTrue($field->validate($validator), "Validates when both passwords are the same");
     $field->setName("TestNew");
     //try changing name of field
     $this->assertTrue($field->validate($validator), "Validates when field name is changed");
     //non-matching password should make the field invalid
     $field->setValue(array("_Password" => "abc123", "_ConfirmPassword" => "123abc"));
     $this->assertFalse($field->validate($validator), "Does not validate when passwords differ");
 }
 /**
  * EditProfileForm 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 TextField $surname */
     $surname = TextField::create('Surname');
     $surname->setAttribute('placeholder', 'Enter your surname')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Surname</strong>')->setCustomValidationMessage('Please enter your <strong>Surname</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 ConfirmedPasswordField $confirmPassword */
     $confirmPassword = ConfirmedPasswordField::create('Password', 'New Password');
     $confirmPassword->canBeEmpty = true;
     $confirmPassword->setAttribute('placeholder', 'Enter your password');
     /** @var LiteralField $passwordToggle */
     $passwordToggle = LiteralField::create('', '<p><button class="btn--default" type="button" data-toggle="collapse" data-target="#togglePassword" aria-expanded="false" aria-controls="togglePassword">Change Password</button></p><div class="collapse" id="togglePassword">');
     $passwordToggleClose = LiteralField::create('', '</div>');
     $fields = FieldList::create($firstName, $surname, $email, $passwordToggle, $confirmPassword, $passwordToggleClose);
     /** -----------------------------------------
      * Actions
      * ----------------------------------------*/
     $actions = FieldList::create(FormAction::create('Save')->setTitle('Update Profile')->addExtraClass('btn--primary'));
     /** -----------------------------------------
      * Validation
      * ----------------------------------------*/
     $required = RequiredFields::create('FirstName', 'Surname', 'Email');
     /** @var Form $form */
     $form = Form::create($this, $name, $fields, $actions, $required);
     /**
      * Populate the form with the current members data
      */
     $Member = Member::currentUser();
     $form->loadDataFrom($Member->data());
     parent::__construct($controller, $name, $fields, $actions, $required);
     $this->setAttribute('data-parsley-validate', true);
     $this->addExtraClass('form form--profile');
 }
 /**
  * getCMSFields
  * Alter the FieldList provided by the Member class to 
  * the requirements of an online store.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     $fields = parent::getCMSFields();
     /** REMOVE SCAFFOLDED FIELDS TO ADD LATER
      * -- Locale is removed. As these users will not use the CMS itself so the default values will suffice for now.
      * -- DirectGroups is removed. Customer group membership is handled by onAfterWrite().
      * -- DateFormat and TimeFormat are removed. The default will be fine for nearly all installations.
      * -- Those fields not mentioned are re-added later.
      */
     $fields->removeFieldsFromTab("Root.Main", array("FirstName", "Surname", "CompanyName", "Email", "Password", "StoreCredit", "LandlineNumber", "MobileNumber", "DirectGroups", "Locale", "FailedLoginCount", "LastVisited", "TimeFormat", "DateFormat"));
     //If the customer record has been created, display the ID of the record as the account number.
     if ($this->exists()) {
         $fields->addFieldsToTab("Root.Main", array(HeaderField::create("Account Details"), CompositeField::create(ReadonlyField::create("AccountNo", "Account Number", $this->ID), ReadonlyField::create("LastVisited", "Last Signed In", $this->LastVisited), NumericField::create("StoreCredit", "StoreCredit")->setRightTitle("The amount of credit this customer can spend on orders in your store."))));
     }
     //Add Customer Details Fields
     $fields->addFieldsToTab("Root.Main", array(HeaderField::create("Customer Details"), CompositeField::create(TextField::create("FirstName", "First Name"), TextField::create("Surname", "Surname"), TextField::create("CompanyName", "Company Name"), TextField::create("LandlineNumber", "Landline Number"), TextField::create("MobileNumber", "Mobile Number")), HeaderField::create("Login Details"), CompositeField::create(EmailField::create("Email", "Email Address"), NumericField::create("FailedLoginCount", "Failed Login Count")->setRightTitle("The total number of failed login attempts this customer has made. Set to 0 to unblock their account."))));
     //Add Confirmed Password Field befoe the FailedLoginCount field
     $password = ConfirmedPasswordField::create('Password', null, null, null, true)->setCanBeEmpty(true);
     if (!$this->ID) {
         $password->showOnClick = false;
     }
     $fields->addFieldToTab("Root.Main", $password, "FailedLoginCount");
     //Customer Address Book Tab
     $fields->addFieldsToTab("Root.AddressBook", array(HeaderField::create($this->exists() ? $this->FirstName . " " . $this->Surname . "'s Address Book" : "Customer Address Book"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\tThe address book is used to store multiple customer addresses for shipping and billing purposes.\n\t\t\t\t\t</div>"), $this->exists() ? GridField::create("Customer_AddressBook", "", $this->Addresses(), GridFieldConfig_RecordEditor::create()) : LiteralField::create($title = "AddressBookNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\tThis customer doesn't exist in the system yet. To be able to see addresses for this customer you must first \n\t\t\t\t\t\t\tclick create.\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\n\t\t\t\t\t</div>"))));
     //Customer Orders Tab
     $fields->addFieldsToTab("Root.Orders", array(HeaderField::create($this->exists() ? $this->FirstName . " " . $this->Surname . "'s Orders" : "Customer Orders"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\tIf this customer has placed orders with your store you can see them below.\n\t\t\t\t\t</div>"), $this->exists() ? GridField::create("Customers_Orders", "", $this->Orders(), GridFieldConfig_RecordEditor::create()) : LiteralField::create($title = "OrdersNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\tThis customer doesn't exist in the system yet. To be able to see orders for this customer you must first \n\t\t\t\t\t\t\tclick create.\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\n\t\t\t\t\t</div>"))));
     //Update Store Credit Field
     $storecredit = NumericField::create("StoreCredit", "Store Credit (" . Product::getDefaultCurrency() . ")");
     $fields->replaceField("StoreCredit", $storecredit);
     //Remove Automatically Generated Address GridField
     $fields->removeFieldFromTab("Root", "Addresses");
     $fields->removeFieldFromTab("Root", "Permissions");
     $fields->removeFieldFromTab("Root.Orders", "Orders");
     return $fields;
 }
Beispiel #18
0
 /**
  * Builds "Change / Create Password" field for this member
  *
  * @return ConfirmedPasswordField
  */
 public function getMemberPasswordField()
 {
     $editingPassword = $this->isInDB();
     $label = $editingPassword ? _t('Member.EDIT_PASSWORD', 'New Password') : $this->fieldLabel('Password');
     /** @var ConfirmedPasswordField $password */
     $password = ConfirmedPasswordField::create('Password', $label, null, null, $editingPassword);
     // If editing own password, require confirmation of existing
     if ($editingPassword && $this->ID == Member::currentUserID()) {
         $password->setRequireExistingPassword(true);
     }
     $password->setCanBeEmpty(true);
     $this->extend('updateMemberPasswordField', $password);
     return $password;
 }
 function Field()
 {
     Requirements::javascript(ECOMMERCE_DIR . '/javascript/OptionalConfirmedPasswordField.js');
     Requirements::block(SAPPHIRE_DIR . '/javascript/ConfirmedPasswordField.js');
     return parent::Field();
 }
Beispiel #20
0
 /**
  * Return a {@link FieldList} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldList Return a FieldList of fields that would appropriate for
  *                   editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
         $password = new ConfirmedPasswordField('Password', null, null, null, true);
         $password->setCanBeEmpty(true);
         if (!$self->ID) {
             $password->showOnClick = false;
         }
         $mainFields->replaceField('Password', $password);
         $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", 'Language of the CMS'), i18n::get_existing_translations()));
         $mainFields->removeByName('RememberLoginToken');
         $mainFields->removeByName('AutoLoginHash');
         $mainFields->removeByName('AutoLoginExpired');
         $mainFields->removeByName('PasswordEncryption');
         $mainFields->removeByName('PasswordExpiry');
         $mainFields->removeByName('LockedOutUntil');
         if (!$self->config()->lock_out_after_incorrect_logins) {
             $mainFields->removeByName('FailedLoginCount');
         }
         $mainFields->removeByName('Salt');
         $mainFields->removeByName('NumVisit');
         $mainFields->makeFieldReadonly('LastVisited');
         $fields->removeByName('Subscriptions');
         // Groups relation will get us into logical conflicts because
         // Members are displayed within  group edit form in SecurityAdmin
         $fields->removeByName('Groups');
         if (Permission::check('EDIT_PERMISSIONS')) {
             $groupsMap = array();
             foreach (Group::get() as $group) {
                 // Listboxfield values are escaped, use ASCII char instead of &raquo;
                 $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
             }
             asort($groupsMap);
             $fields->addFieldToTab('Root.Main', ListboxField::create('DirectGroups', singleton('Group')->i18n_plural_name())->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')));
             // Add permission field (readonly to avoid complicated group assignment logic).
             // This should only be available for existing records, as new records start
             // with no permissions until they have a group assignment anyway.
             if ($self->ID) {
                 $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', false, 'Permission', 'GroupID', $self->getManyManyComponents('Groups'));
                 $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
                 $fields->addFieldToTab('Root.Permissions', $permissionsField);
             }
         }
         $permissionsTab = $fields->fieldByName("Root")->fieldByName('Permissions');
         if ($permissionsTab) {
             $permissionsTab->addExtraClass('readonly');
         }
         $defaultDateFormat = Zend_Locale_Format::getDateFormat(new Zend_Locale($self->Locale));
         $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
         $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($dateFormatField = new MemberDatetimeOptionsetField('DateFormat', $self->fieldLabel('DateFormat'), $dateFormatMap));
         $dateFormatField->setValue($self->DateFormat);
         $defaultTimeFormat = Zend_Locale_Format::getTimeFormat(new Zend_Locale($self->Locale));
         $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
         $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($timeFormatField = new MemberDatetimeOptionsetField('TimeFormat', $self->fieldLabel('TimeFormat'), $timeFormatMap));
         $timeFormatField->setValue($self->TimeFormat);
     });
     return parent::getCMSFields();
 }
Beispiel #21
0
 public function SignUp()
 {
     return Form::create($this, 'SignUp', FieldList::create(TextField::create('FirstName'), TextField::create('Surname'), EmailField::create('Email'), ConfirmedPasswordField::create('Password', 'Password'), CheckboxField::create('Terms', 'I accept the <a href="/terms-and-conditions">terms and conditions</a>')), FieldList::create(FormAction::create('Register')->setTitle('Register')), new RequiredFields(array('FirstName', 'Surename', 'Password', 'Email', 'Terms')));
 }
Beispiel #22
0
 /**
  * Return a {@link FieldSet} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldSet Return a FieldSet of fields that would appropriate for
  *                  editing this member.
  */
 public function getCMSFields()
 {
     $locale = $this->Locale ? $this->Locale : i18n::get_locale();
     $password = new ConfirmedPasswordField('Password', 'Password');
     $password->setCanBeEmpty(true);
     $fields = new FieldSet(new HeaderField(_t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')), new TextField("FirstName", _t('Member.FIRSTNAME')), new TextField("Surname", _t('Member.SURNAME')), new HeaderField(_t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')), new TextField("Email", _t('Member.EMAIL')), new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), i18n::get_existing_translations(), $locale), $password);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Creates the registration form
  *
  * @return  BootstrapForm
  */
 public function RegistrationForm()
 {
     $speaker_registration_token = Session::get(SpeakerRegistrationRequest::ConfirmationTokenParamName);
     $fields = FieldList::create($first_name = TextField::create('FirstName', 'Your First Name'), $last_name = TextField::create('Surname', 'Your Last Name'), $email = EmailField::create('Email', 'Your email address'), $password = ConfirmedPasswordField::create('Password', 'Password'));
     $password->setAttribute('required', 'true');
     //if we have in session a registration token, autopopulate values
     if (!empty($speaker_registration_token)) {
         $request = $this->speaker_registration_request_repository->getByConfirmationToken($speaker_registration_token);
         if (is_null($request) || $request->alreadyConfirmed()) {
             return $this->httpError(404, 'speaker registration request not found!');
         }
         $first_name->setValue($request->proposedSpeakerFirstName());
         $last_name->setValue($request->proposedSpeakerLastName());
         $email->setValue($request->proposedSpeakerEmail());
     }
     $form = BootstrapForm::create($this, 'RegistrationForm', $fields, FieldList::create(FormAction::create('doRegister', 'Register now')), RequiredFields::create('FirstName', 'Surname', 'Email'));
     $data = Session::get("FormInfo.{$form->getName()}.data");
     return $form->loadDataFrom($data ?: array());
 }
 /**
  * Registration form
  *
  * @return Form
  */
 public function RegisterForm()
 {
     // If back URL set, push to session
     if (isset($_REQUEST['BackURL'])) {
         Session::set('BackURL', $_REQUEST['BackURL']);
     }
     // Setup form fields
     $fields = FieldList::create(TextField::create("FirstName"), TextField::create("Surname"), EmailField::create("Email"), ConfirmedPasswordField::create("Password"));
     // Setup form actions
     $actions = new FieldList(FormAction::create("doRegister", "Register")->addExtraClass("btn")->addExtraClass("btn-green"));
     // Setup required fields
     $required = new RequiredFields(array("FirstName", "Surname", "Email", "Password"));
     $form = Form::create($this, "RegisterForm", $fields, $actions, $required)->addExtraClass("forms")->addExtraClass("forms-columnar");
     $this->extend("updateRegisterForm", $form);
     $session_data = Session::get("Form.{$form->FormName()}.data");
     if ($session_data && is_array($session_data)) {
         $form->loadDataFrom($session_data);
         Session::clear("Form.{$form->FormName()}.data");
     }
     return $form;
 }
Beispiel #25
0
	/**
	 * Return a {@link FieldSet} of fields that would appropriate for editing
	 * this member.
	 *
	 * @return FieldSet Return a FieldSet of fields that would appropriate for
	 *                  editing this member.
	 */
	public function getCMSFields() {
		$fields = parent::getCMSFields();
		
		$mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
		
		$password = new ConfirmedPasswordField(
			'Password', 
			null, 
			null, 
			null, 
			true // showOnClick
		);
		$password->setCanBeEmpty(true);
		if(!$this->ID) $password->showOnClick = false;
		$mainFields->replaceField('Password', $password);
		
		$mainFields->insertBefore(
			new HeaderField('MemberDetailsHeader',_t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')),
			'FirstName'
		);
		
		$mainFields->insertBefore(
			new HeaderField('MemberUserDetailsHeader',_t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')),
			'Email'
		);
		
		$locale = ($this->Locale) ? $this->Locale : i18n::get_locale();
		$mainFields->replaceField('Locale', new DropdownField(
			"Locale", 
			_t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), 
			i18n::get_existing_translations(), 
			$locale
		));
		
		$mainFields->removeByName('Bounced');
		$mainFields->removeByName('RememberLoginToken');
		$mainFields->removeByName('AutoLoginHash');
		$mainFields->removeByName('AutoLoginExpired');
		$mainFields->removeByName('PasswordEncryption');
		$mainFields->removeByName('PasswordExpiry');
		$mainFields->removeByName('LockedOutUntil');
		$mainFields->removeByName('Salt');
		$mainFields->removeByName('NumVisit');
		$mainFields->removeByName('LastVisited');
	
		$fields->removeByName('Subscriptions');
		// Groups relation will get us into logical conflicts because
		// Members are displayed within  group edit form in SecurityAdmin
		$fields->removeByName('Groups');

		$this->extend('updateCMSFields', $fields);
		
		return $fields;
	}
 /**
  * @param string $name
  * @param string $title
  * @param mixed $value
  * @param Form $form
  * @param boolean $showOnClick
  * @param string $titleConfirmField Alternate title (not localizeable)
  */
 public function __construct($name, $title = null, $value = "", $form = null, $showOnClick = false, $titleConfirmField = null)
 {
     parent::__construct($name, $title, $value, $form, $showOnClick, $titleConfirmField);
     $this->setValue($value);
     $this->setTitle($title);
 }
 function __construct($controller, $name)
 {
     //requirements
     Requirements::javascript('ecommerce/javascript/EcomOrderFormAddress.js');
     // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         Requirements::javascript('ecommerce/javascript/EcomOrderFormShipping.js');
         // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     }
     //set basics
     $order = ShoppingCart::current_order();
     $requiredFields = array();
     //  ________________ 1) Member + Address fields
     //find member
     $this->orderMember = $order->CreateOrReturnExistingMember(false);
     $this->loggedInMember = Member::currentUser();
     //strange security situation...
     if ($this->orderMember->exists() && $this->loggedInMember) {
         if ($this->orderMember->ID != $this->loggedInMember->ID) {
             if (!$this->loggedInMember->IsShopAdmin()) {
                 $this->loggedInMember->logOut();
             }
         }
     }
     $addressFieldsBilling = new FieldSet();
     //member fields
     if ($this->orderMember) {
         $memberFields = $this->orderMember->getEcommerceFields();
         $requiredFields = array_merge($requiredFields, $this->orderMember->getEcommerceRequiredFields());
         $addressFieldsBilling->merge($memberFields);
     }
     //billing address field
     $billingAddress = $order->CreateOrReturnExistingAddress("BillingAddress");
     $billingAddressFields = $billingAddress->getFields($this->orderMember);
     $requiredFields = array_merge($requiredFields, $billingAddress->getRequiredFields());
     $addressFieldsBilling->merge($billingAddressFields);
     //shipping address field
     $addressFieldsShipping = null;
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         $addressFieldsShipping = new FieldSet();
         //add the important CHECKBOX
         $useShippingAddressField = new FieldSet(new CheckboxField("UseShippingAddress", _t("OrderForm.USESHIPPINGADDRESS", "Use an alternative shipping address")));
         $addressFieldsShipping->merge($useShippingAddressField);
         //now we can add the shipping fields
         $shippingAddress = $order->CreateOrReturnExistingAddress("ShippingAddress");
         $shippingAddressFields = $shippingAddress->getFields($this->orderMember);
         //we have left this out for now as it was giving a lot of grief...
         //$requiredFields = array_merge($requiredFields, $shippingAddress->getRequiredFields());
         //finalise left fields
         $addressFieldsShipping->merge($shippingAddressFields);
     }
     $leftFields = new CompositeField($addressFieldsBilling);
     $leftFields->setID('LeftOrderBilling');
     $allLeftFields = new CompositeField($leftFields);
     $allLeftFields->setID('LeftOrder');
     if ($addressFieldsShipping) {
         $leftFieldsShipping = new CompositeField($addressFieldsShipping);
         $leftFieldsShipping->setID('LeftOrderShipping');
         $allLeftFields->push($leftFieldsShipping);
     }
     //  ________________  2) Log in / vs Create Account fields - RIGHT-HAND-SIDE fields
     $rightFields = new CompositeField();
     $rightFields->setID('RightOrder');
     //to do: simplify
     if (EcommerceConfig::get("EcommerceRole", "allow_customers_to_setup_accounts")) {
         if ($this->orderDoesNotHaveFullyOperationalMember()) {
             //general header
             if (!$this->loggedInMember) {
                 $rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . _t('OrderForm.MEMBERINFO', 'If you are already have an account then please') . " <a href=\"Security/login/?BackURL=" . urlencode($controller->Link()) . "\">" . _t('OrderForm.LOGIN', 'log in') . '</a>.</p>'));
             }
             $passwordField = new ConfirmedPasswordField('Password', _t('OrderForm.PASSWORD', 'Password'));
             //login invite right on the top
             if (EcommerceConfig::get("EcommerceRole", "automatic_membership")) {
                 $rightFields->push(new HeaderField('CreateAnAccount', _t('OrderForm.CREATEANACCONTOPTIONAL', 'Create an account (optional)'), 3));
                 //allow people to purchase without creating a password
                 $passwordField->setCanBeEmpty(true);
             } else {
                 $rightFields->push(new HeaderField('SetupYourAccount', _t('OrderForm.SETUPYOURACCOUNT', 'Setup your account'), 3));
                 //dont allow people to purchase without creating a password
                 $passwordField->setCanBeEmpty(false);
             }
             $requiredFields[] = 'Password[_Password]';
             $requiredFields[] = 'Password[_ConfirmPassword]';
             Requirements::customScript('jQuery("#ChoosePassword").click();', "EommerceChoosePassword");
             // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
             $rightFields->push(new LiteralField('AccountInfo', '<p>' . _t('OrderForm.ACCOUNTINFO', 'Please <a href="#Password" class="choosePassword">choose a password</a>; this will allow you can log in and check your order history in the future.') . '</p>'));
             $rightFields->push(new FieldGroup($passwordField));
         } else {
             if ($this->loggedInMember) {
                 $rightFields->push(new LiteralField('LoginNote', "<p class=\"message good\">" . _t("Account.LOGGEDIN", "You are logged in as ") . $this->loggedInMember->FirstName . ' ' . $this->loggedInMember->Surname . ' (' . $this->loggedInMember->Email . ').</p>'));
             }
         }
         if ($this->orderMember->exists()) {
             if ($this->loggedInMember) {
                 if ($this->loggedInMember->ID != $this->orderMember->ID) {
                     $rightFields->push(new LiteralField('OrderAddedTo', "<p class=\"message good\">" . _t("Account.ORDERADDEDTO", "Order will be added to ") . $this->orderMember->FirstName . ' ' . $this->orderMember->Surname . ' (' . $this->orderMember->Email . ').</p>'));
                 }
             }
         }
     }
     //  ________________  5) Put all the fields in one FieldSet
     $fields = new FieldSet($rightFields, $allLeftFields);
     //  ________________  6) Actions and required fields creation + Final Form construction
     $nextButton = new FormAction('saveAddress', _t('OrderForm.NEXT', 'Next'));
     $nextButton->addExtraClass("next");
     $actions = new FieldSet($nextButton);
     $validator = new OrderFormAddress_Validator($requiredFields);
     //TODO: do we need this here?
     $validator->setJavascriptValidationHandler("prototype");
     parent::__construct($controller, $name, $fields, $actions, $validator);
     //extensions need to be set after __construct
     if ($this->extend('updateFields', $fields) !== null) {
         $this->setFields($fields);
     }
     if ($this->extend('updateActions', $actions) !== null) {
         $this->setActions($actions);
     }
     if ($this->extend('updateValidator', $validator) !== null) {
         $this->setValidator($validator);
     }
     //  ________________  7)  Load saved data
     //we do this first so that Billing and Shipping Address can override this...
     if ($this->orderMember) {
         $this->loadDataFrom($this->orderMember);
     }
     if ($order) {
         $this->loadDataFrom($order);
         if ($billingAddress) {
             $this->loadDataFrom($billingAddress);
         }
         if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
             if ($shippingAddress) {
                 $this->loadDataFrom($shippingAddress);
             }
         }
     }
     //allow updating via decoration
     $this->extend('updateOrderFormAddress', $this);
 }
Beispiel #28
0
 /**
  * Return a {@link FieldSet} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldSet Return a FieldSet of fields that would appropriate for
  *                  editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $fields = parent::getCMSFields();
     $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
     $password = new ConfirmedPasswordField('Password', null, null, null, true);
     $password->setCanBeEmpty(true);
     if (!$this->ID) {
         $password->showOnClick = false;
     }
     $mainFields->replaceField('Password', $password);
     $mainFields->insertBefore(new HeaderField('MemberDetailsHeader', _t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')), 'FirstName');
     $mainFields->insertBefore(new HeaderField('MemberUserDetailsHeader', _t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')), 'Email');
     $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), i18n::get_existing_translations()));
     $mainFields->removeByName('Bounced');
     $mainFields->removeByName('RememberLoginToken');
     $mainFields->removeByName('AutoLoginHash');
     $mainFields->removeByName('AutoLoginExpired');
     $mainFields->removeByName('PasswordEncryption');
     $mainFields->removeByName('PasswordExpiry');
     $mainFields->removeByName('LockedOutUntil');
     if (!self::$lock_out_after_incorrect_logins) {
         $mainFields->removeByName('FailedLoginCount');
     }
     $mainFields->removeByName('Salt');
     $mainFields->removeByName('NumVisit');
     $mainFields->removeByName('LastVisited');
     $fields->removeByName('Subscriptions');
     // Groups relation will get us into logical conflicts because
     // Members are displayed within  group edit form in SecurityAdmin
     $fields->removeByName('Groups');
     if (Permission::check('EDIT_PERMISSIONS')) {
         $groupsField = new TreeMultiselectField('Groups', false, 'Group');
         $fields->findOrMakeTab('Root.Groups', singleton('Group')->i18n_plural_name());
         $fields->addFieldToTab('Root.Groups', $groupsField);
         // Add permission field (readonly to avoid complicated group assignment logic).
         // This should only be available for existing records, as new records start
         // with no permissions until they have a group assignment anyway.
         if ($this->ID) {
             $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', singleton('Permission')->i18n_plural_name(), 'Permission', 'GroupID', $this->getManyManyComponents('Groups'));
             $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
             $fields->addFieldToTab('Root.Permissions', $permissionsField);
         }
     }
     $defaultDateFormat = Zend_Locale_Format::getDateFormat($this->Locale);
     $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
     $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
     $mainFields->push($dateFormatField = new Member_DatetimeOptionsetField('DateFormat', $this->fieldLabel('DateFormat'), $dateFormatMap));
     $dateFormatField->setValue($this->DateFormat);
     $defaultTimeFormat = Zend_Locale_Format::getTimeFormat($this->Locale);
     $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
     $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
     $mainFields->push($timeFormatField = new Member_DatetimeOptionsetField('TimeFormat', $this->fieldLabel('TimeFormat'), $timeFormatMap));
     $timeFormatField->setValue($this->TimeFormat);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 function __construct($controller, $name)
 {
     //Requirements::themedCSS('OrderForm');
     // 1) Member and shipping fields
     $member = Member::currentUser();
     $memberFields = new CompositeField(singleton('Member')->getEcommerceFields());
     $requiredFields = singleton('Member')->getEcommerceRequiredFields();
     if (ShoppingCart::uses_different_shipping_address()) {
         $countryField = new DropdownField('ShippingCountry', _t('OrderForm.Country', 'Country'), Geoip::getCountryDropDown(), EcommerceRole::find_country());
         $shippingFields = new CompositeField(new HeaderField(_t('OrderForm.SendGoodsToDifferentAddress', 'Send goods to different address'), 3), new LiteralField('ShippingNote', '<p class="message warning">' . _t('OrderForm.ShippingNote', 'Your goods will be sent to the address below.') . '</p>'), new LiteralField('Help', '<p>' . _t('OrderForm.Help', 'You can use this for gift giving. No billing information will be disclosed to this address.') . '</p>'), new TextField('ShippingName', _t('OrderForm.Name', 'Name')), new TextField('ShippingAddress', _t('OrderForm.Address', 'Address')), new TextField('ShippingAddress2', _t('OrderForm.Address2', '')), new TextField('ShippingCity', _t('OrderForm.City', 'City')), $countryField, new HiddenField('UseShippingAddress', '', true), $changeshippingbutton = new FormAction_WithoutLabel('useMemberShippingAddress', _t('OrderForm.UseBillingAddress', 'Use Billing Address for Shipping')));
         //Need to to this because 'FormAction_WithoutLabel' has no text on the actual button
         $changeshippingbutton->setButtonContent(_t('OrderForm.UseBillingAddress', 'Use Billing Address for Shipping'));
         $changeshippingbutton->useButtonTag = true;
         $requiredFields[] = 'ShippingName';
         $requiredFields[] = 'ShippingAddress';
         $requiredFields[] = 'ShippingCity';
         $requiredFields[] = 'ShippingCountry';
     } else {
         $countryField = $memberFields->fieldByName('Country');
         $shippingFields = new FormAction_WithoutLabel('useDifferentShippingAddress', _t('OrderForm.useDifferentShippingAddress', 'Use Different Shipping Address'));
         //Need to to this because 'FormAction_WithoutLabel' has no text on the actual button
         $shippingFields->setButtonContent(_t('OrderForm.useDifferentShippingAddress', 'Use Different Shipping Address'));
         $shippingFields->useButtonTag = true;
     }
     if ($countryField) {
         $countryField->addExtraClass('ajaxCountryField');
         $setCountryLinkID = $countryField->id() . '_SetCountryLink';
         $setContryLink = ShoppingCart::set_country_link();
         $memberFields->push(new HiddenField($setCountryLinkID, '', $setContryLink));
     }
     $leftFields = new CompositeField($memberFields, $shippingFields);
     $leftFields->setID('LeftOrder');
     $rightFields = new CompositeField();
     $rightFields->setID('RightOrder');
     if (!$member) {
         $rightFields->push(new HeaderField(_t('OrderForm.MembershipDetails', 'Membership Details'), 3));
         $rightFields->push(new LiteralField('MemberInfo', '<p class="message warning">' . _t('OrderForm.MemberInfo', 'If you are already a member please') . " <a href=\"Security/login?BackURL=" . CheckoutPage::find_link(true) . "/\">" . _t('OrderForm.LogIn', 'log in') . '</a>.</p>'));
         $rightFields->push(new LiteralField('AccountInfo', '<p>' . _t('OrderForm.AccountInfo', 'Please choose a password, so you can login and check your order history in the future') . '</p><br/>'));
         $rightFields->push(new FieldGroup($pwf = new ConfirmedPasswordField('Password', _t('OrderForm.Password', 'Password'))));
         //if user doesn't fill out password, we assume they don't want to become a member
         //TODO: allow different ways of specifying that you want to become a member
         if (self::$user_membership_optional) {
             $pwf->setCanBeEmpty(true);
         }
         if (self::$force_membership || !self::$user_membership_optional) {
             $requiredFields[] = 'Password[_Password]';
             $requiredFields[] = 'Password[_ConfirmPassword]';
             //TODO: allow extending this to provide other ways of indicating that you want to become a member
         }
     } else {
         $rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . sprintf(_t('OrderForm.LoggedInAs', 'You are logged in as %s.'), $member->getName()) . " <a href=\"Security/logout?BackURL=" . CheckoutPage::find_link(true) . "/\">" . _t('OrderForm.LogOut', 'log out') . '</a>.</p>'));
     }
     // 2) Payment fields
     $currentOrder = ShoppingCart::current_order();
     $totalobj = DBField::create('Currency', $currentOrder->Total());
     //should instead be $totalobj = $currentOrder->dbObject('Total');
     $paymentFields = Payment::combined_form_fields($totalobj->Nice());
     foreach ($paymentFields as $field) {
         $rightFields->push($field);
     }
     if ($paymentRequiredFields = Payment::combined_form_requirements()) {
         $requiredFields = array_merge($requiredFields, $paymentRequiredFields);
     }
     // 3) Put all the fields in one FieldSet
     $fields = new FieldSet($leftFields, $rightFields);
     // 4) Terms and conditions field
     // If a terms and conditions page exists, we need to create a field to confirm the user has read it
     if ($controller->TermsPageID && ($termsPage = $controller->TermsPage())) {
         $bottomFields = new CompositeField(new CheckboxField('ReadTermsAndConditions', sprintf(_t('OrderForm.TERMSANDCONDITIONS', "I agree to the terms and conditions stated on the <a href=\"%s\" title=\"Read the shop terms and conditions for this site\">terms and conditions</a> page"), $termsPage->Link())));
         $bottomFields->setID('BottomOrder');
         $fields->push($bottomFields);
         $requiredFields[] = 'ReadTermsAndConditions';
         //TODO: this doesn't work for check-boxes
     }
     // 5) Actions and required fields creation
     $actions = new FieldSet(new FormAction('processOrder', _t('OrderForm.processOrder', 'Place order and make payment')));
     $requiredFields = new CustomRequiredFields($requiredFields);
     $this->extend('updateValidator', $requiredFields);
     $this->extend('updateFields', $fields);
     // 6) Form construction
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     // 7) Member details loading
     if ($member && $member->ID) {
         $this->loadDataFrom($member);
     }
     // 8) Country field value update
     if ($countryField) {
         $currentOrder = ShoppingCart::current_order();
         $currentOrderCountry = $currentOrder->findShippingCountry(true);
         $countryField->setValue($currentOrderCountry);
     }
     //allow updating via decoration
     $this->extend('updateForm', $this);
 }