function __construct($controller, $name, $use_actions = true) { $fields = new FieldList(); //point of contact $fields->push($point_of_contact_name = new TextField('point_of_contact_name', 'Name')); $fields->push($point_of_contact_email = new EmailField('point_of_contact_email', 'Email')); //main info $fields->push($title = new TextField('title', 'Title')); $fields->push($url = new TextField('url', 'Url')); $fields->push(new CheckboxField('is_coa_needed', 'Is COA needed?')); $fields->push($ddl_type = new DropdownField('job_type', 'Job Type', JobType::get()->sort("Type")->map("ID", "Type"))); $ddl_type->setEmptyString("--SELECT A JOB TYPE --"); $fields->push($description = new HtmlEditorField('description', 'Description')); $fields->push($instructions = new HtmlEditorField('instructions', 'Instructions To Apply')); $fields->push($expiration_date = new TextField('expiration_date', 'Expiration Date')); $fields->push($company = new CompanyField('company', 'Company')); $point_of_contact_name->addExtraClass('job_control'); $point_of_contact_email->addExtraClass('job_control'); $title->addExtraClass('job_control'); $url->addExtraClass('job_control'); $description->addExtraClass('job_control'); $instructions->addExtraClass('job_control'); $expiration_date->addExtraClass('job_control'); $company->addExtraClass('job_control'); //location $ddl_locations = new DropdownField('location_type', 'Location Type', array('N/A' => 'N/A', 'Remote' => 'Remote', 'Various' => 'Add a Location')); $ddl_locations->addExtraClass('location_type'); $ddl_locations->addExtraClass('job_control'); $fields->push($ddl_locations); $fields->push($city = new TextField('city', 'City')); $fields->push($state = new TextField('state', 'State')); $fields->push($country = new CountryDropdownField('country', 'Country')); $city->addExtraClass('physical_location'); $state->addExtraClass('physical_location'); $country->addExtraClass('physical_location'); // Guard against automated spam registrations by optionally adding a field // that is supposed to stay blank (and is hidden from most humans). // The label and field name are intentionally common ("username"), // as most spam bots won't resist filling it out. The actual username field // on the forum is called "Nickname". $fields->push(new TextField('user_name', 'UserName')); // Create action $actions = new FieldList(); if ($use_actions) { $actions->push(new FormAction('saveJobRegistrationRequest', 'Save')); } // Create validators $validator = new ConditionalAndValidationRule([new HtmlPurifierRequiredValidator('title', 'instructions', 'description'), new RequiredFields('job_type', 'point_of_contact_name', 'point_of_contact_email')]); $this->addExtraClass('job-registration-form'); $this->addExtraClass('input-form'); parent::__construct($controller, $name, $fields, $actions, $validator); }
function RegistrationForm() { // Name Set $FirstNameField = new TextField('FirstName', "First Name"); $LastNameField = new TextField('Surname', "Last Name"); // Email Addresses $PrimaryEmailField = new TextField('Email', "Primary Email Address"); // New Gender Field $GenderField = new OptionSetField('Gender', 'I identify my gender as:', array('Male' => 'Male', 'Female' => 'Female', 'Specify' => 'Let me specify', 'Prefer not to say' => 'Prefer not to say')); $GenderSpecifyField = new TextField('GenderSpecify', 'Specify your gender'); $GenderSpecifyField->addExtraClass('hide'); $StatementOfInterestField = new TextField('StatementOfInterest', 'Statement of Interest'); $StatementOfInterestField->addExtraClass('autocompleteoff'); $affiliations = new AffiliationField('Affiliations', 'Affiliations'); $affiliations->setMode('local'); $fields = new FieldList($FirstNameField, $LastNameField, new LiteralField('break', '<hr/>'), $PrimaryEmailField, new LiteralField('instructions', '<p>This will also be your login name.</p>'), new LiteralField('break', '<hr/>'), $GenderField, $GenderSpecifyField, new LiteralField('instructions', '<p>It\'s perfectly acceptable if you choose not to tell us: we appreciate you becoming a member of OpenStack Foundation. The information will remain private and only used to monitor our effort to improve gender diversity in our community.</p>'), new LiteralField('break', '<hr/>'), $affiliations, $StatementOfInterestField, new LiteralField('instructions', '<p>Your statement of interest should be a few words describing your objectives or plans for OpenStack.</p>'), new LiteralField('break', '<hr/>'), new TextField('Address', _t('Addressable.ADDRESS', 'Street Address (Line1)')), new TextField('Suburb', _t('Addressable.SUBURB', 'Street Address (Line2)')), new TextField('City', _t('Addressable.CITY', 'City'))); $label = _t('Addressable.STATE', 'State'); if (is_array($this->allowedStates)) { $fields->push(new DropdownField('State', $label, $this->allowedStates)); } elseif (!is_string($this->allowedStates)) { $fields->push(new TextField('State', $label)); } $AdressField = new TextField('Postcode', _t('Addressable.POSTCODE', 'Postcode')); $fields->push($AdressField); $label = _t('Addressable.COUNTRY', 'Country'); if (is_array($this->allowedCountries)) { $countryField = new DropdownField('Country', $label, $this->allowedCountries); $countryField->addExtraClass('chzn-select'); $countryField->setEmptyString('-- Select One --'); $fields->push($countryField); } elseif (!is_string($this->allowedCountries)) { $countryField = new CountryDropdownField('Country', $label); $countryField->setEmptyString('-- Select One --'); $countryField->addExtraClass('chzn-select'); $fields->push($countryField); } $fields->push(new LiteralField('break', '<hr/>')); $fields->push(new ConfirmedPasswordField('Password', 'Password')); $fields->push(new HiddenField('MembershipType', 'MembershipType', 'foundation')); $actions = new FieldList(new FormAction('doRegister', 'Submit My Application')); $validator = new Member_Validator('FirstName', 'Surname', 'Email', 'StatementOfInterest', 'Address', 'City', 'Country', 'Password'); $form = new HoneyPotForm($this, 'RegistrationForm', $fields, $actions, $validator); if ($data = Session::get("FormInfo.{$form->FormName()}.data")) { if (isset($data['HiddenAffiliations'])) { $affiliations->setValue($data['HiddenAffiliations']); } return $form->loadDataFrom($data); } return $form; }
public function updateCMSFields(FieldList $fields) { $geoCountry = new CountryDropdownField('GeoCountry', _t('GeoTags.GEOCOUNTRY', 'Country')); $geoCountry->setRightTitle(_t('GeoTags.GEOCOUNTY_HELP', 'The Country of origin'))->addExtraClass('help'); $geoRegion = new TextField('GeoRegion', _t('GeoTags.GEOREGION', 'REGION')); $geoRegion->setRightTitle(_t('GeoTags.GEOREGION_HELP', 'The Region in the Country of origin. Must use appropriate iso3166 region code'))->addExtraClass('help'); $geoPlacename = new TextField('GeoPlacename', _t('GeoTags.GEOPLACENAME', 'Placename')); $geoPlacename->setRightTitle(_t('GeoTags.GEOPLACENAME_HELP', 'The Placename tag is provided primarily for resource recognition; it is anticipated that this field be harvested by automated agents and presented to the user in search engine results in a similar manner to the description META tag. This field is free-text, and typically would be used for city, county and state names. It could, however, be used for resource discovery'))->addExtraClass('help'); $geoLong = new TextField('GeoLongitude', _t('GeoTags.GEOLONGITUDE', 'Longitude')); $geoLong->setRightTitle(_t('GeoTags.GEOLONGITUDE_HELP', 'The Longitude for the location'))->addExtraClass('help'); $geoLat = new TextField('GeoLatitude', _t('GeoTags.GEOLATITUDE', 'Latitude')); $geoLat->setRightTitle(_t('GeoTags.GEOLATITUDE_HELP', 'The Latitude for the location'))->addExtraClass('help'); $fields->addFieldsToTab('Root.GeoTags', array($geoCountry, $geoRegion, $geoPlacename, $geoLong, $geoLat)); return $fields; }
/** * getCMSFields * Construct the FieldList used in the CMS. To provide a * smarter UI we don't use the scaffolding provided by * parent::getCMSFields. * * @return FieldList */ public function getCMSFields() { Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css'); //Create the FieldList and push the Root TabSet on to it. $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Tax Zone"), CompositeField::create(DropdownField::create("Enabled", "Enable this zone?", array("1" => "Yes", "2" => "No"))->setRightTitle($this->SystemCreated == 1 && $this->exists() ? "DISABLED: You can not disable the default tax zone." : "If enabled your store will use the rates defined in this zone for customers in the selected country.")->setDisabled($this->SystemCreated == 1 && $this->exists() ? true : false), !$this->exists() ? CountryDropdownField::create("Title", "Country")->setRightTitle($this->SystemCreated == 1 && $this->exists() ? "DISABLED: You can not select a country as this zone applies to all countries." : "Select the country this zone applies to.")->setDisabled($this->SystemCreated == 1 && $this->exists() ? true : false) : "", $this->exists() ? GridField::create("TaxZones_TaxRates", "Tax Rates within the '" . $this->Title . "' Tax Zone", $this->TaxRates(), GridFieldConfig_RecordEditor::create()) : "")))); return $fields; }
function TypoForm() { $array = array('green', 'yellow', 'blue', 'pink', 'orange'); $form = new Form($this, 'TestForm', $fields = FieldList::create(HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), TextField::create('TextField1', 'Text Field Example 1'), TextField::create('TextField2', 'Text Field Example 2'), TextField::create('TextField3', 'Text Field Example 3'), TextField::create('TextField4', ''), HeaderField::create('HeaderField2b', 'Field with right title', 2), $textAreaField = new TextareaField('TextareaField', 'Textarea Field'), EmailField::create('EmailField', 'Email address'), HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), OptionsetField::create('OptionSF', 'Optionset Field', $array), CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), CountryDropdownField::create('CountryDropdownField', 'Countries'), CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), HeaderField::create('HeaderField3', 'Other Fields', 3), NumericField::create('NumericField', 'Numeric Field '), DateField::create('DateField', 'Date Field'), DateField::create('DateTimeField', 'Date and Time Field'), CheckboxField::create('CheckboxField', 'Checkbox Field')), $actions = FieldList::create(FormAction::create('submit', 'Submit Button')), $requiredFields = RequiredFields::create('TextField1', 'TextField2', 'TextField3', 'ErrorField1', 'ErrorField2', 'EmailField', 'TextField3', 'RightTitleField', 'CheckboxField', 'CheckboxSetField')); $textAreaField->setColumns(45); $form->setMessage('warning message', 'warning'); return $form; }
public function getCMSFields() { $fields = FieldList::create(TabSet::create('Root')); $fields->addFieldsToTab('Root.Main', array(TextField::create('Title'), TextareaField::create('Description'), DropdownField::create('CategoryID', 'Category')->setSource(DirectoryCategory::get()->map('ID', 'Title'))->setEmptyString('-- Select a category --'), TextField::create('Manager'), TextareaField::create('Address'), TextField::create('City'), CountryDropdownField::create('Country'), TextField::create('Website'), TextField::create('Email'), TextField::create('Phone'), DateField::create('Date')->setConfig('showcalendar', true)->setConfig('dateformat', 'd MMMM yyyy'))); $fields->addFieldToTab('Root.Photos', $upload = UploadField::create('Photo', 'Photo')); $upload->getValidator()->setAllowedExtensions(array('png', 'jpeg', 'jpg', 'gif')); $upload->setFolderName('directory-photos'); return $fields; }
function __construct($controller, $name, $use_actions = true) { $fields = new FieldList(); //main info $fields->push($title = new TextField('title', 'Title')); $fields->push($url = new TextField('url', 'Url')); $fields->push($description = new HtmlEditorField('description', 'Description')); $fields->push($instructions = new HtmlEditorField('instructions', 'Instructions To Apply')); $fields->push($expiration_date = new TextField('expiration_date', 'Expiration Date')); $fields->push($company = new TextField('company_name', 'Company')); $title->addExtraClass('job_control'); $url->addExtraClass('job_control'); $description->addExtraClass('job_control'); $instructions->addExtraClass('job_control'); $expiration_date->addExtraClass('job_control'); $company->addExtraClass('job_control'); //location $ddl_locations = new DropdownField('location_type', 'Location Type', array('N/A' => 'N/A', 'Remote' => 'Remote', 'Various' => 'Add a Location')); $ddl_locations->addExtraClass('location_type'); $ddl_locations->addExtraClass('job_control'); $fields->push($ddl_locations); $fields->push($city = new TextField('city', 'City')); $fields->push($state = new TextField('state', 'State')); $fields->push($country = new CountryDropdownField('country', 'Country')); $city->addExtraClass('physical_location'); $state->addExtraClass('physical_location'); $country->addExtraClass('physical_location'); // Guard against automated spam registrations by optionally adding a field // that is supposed to stay blank (and is hidden from most humans). // The label and field name are intentionally common ("username"), // as most spam bots won't resist filling it out. The actual username field // on the forum is called "Nickname". $fields->push(new TextField('user_name', 'UserName')); // Create action $actions = new FieldList(); if ($use_actions) { $actions->push(new FormAction('saveJob', 'Save')); } // Create validators $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'company_name', 'instructions', 'description'))); $this->addExtraClass('job-registration-form'); parent::__construct($controller, $name, $fields, $actions, $validator); }
function __construct($controller, $name, $use_actions = true) { $event_manager = new EventManager($this->repository, new EventRegistrationRequestFactory(), null, new SapphireEventPublishingService(), new EventValidatorFactory(), SapphireTransactionManager::getInstance()); $fields = new FieldList(); //point of contact $fields->push(new TextField('point_of_contact_name', 'Name')); $fields->push(new EmailField('point_of_contact_email', 'Email')); //main info $fields->push(new TextField('title', 'Title')); $fields->push(new TextField('url', 'Url')); $types = $event_manager->getAllTypes(); foreach ($types as $type) { $options[$type] = $type; } $categoryField = new DropdownField('category', 'Category', $options); $categoryField->setEmptyString('-- select a category --'); $fields->push($categoryField); //location $fields->push(new TextField('city', 'City')); $fields->push(new TextField('state', 'State')); $countryField = new CountryDropdownField('country', 'Country'); $countryField->setEmptyString('-- select a country --'); $fields->push($countryField); //duration $fields->push($start_date = new TextField('start_date', 'Start Date')); $fields->push($end_date = new TextField('end_date', 'End Date')); $start_date->addExtraClass('date'); $end_date->addExtraClass('date'); // Guard against automated spam registrations by optionally adding a field // that is supposed to stay blank (and is hidden from most humans). // The label and field name are intentionally common ("username"), // as most spam bots won't resist filling it out. The actual username field // on the forum is called "Nickname". $fields->push(new TextField('user_name', 'UserName')); // Create action $actions = new FieldList(); if ($use_actions) { $actions->push(new FormAction('saveEventRegistrationRequest', 'Save')); } // Create validators $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'city'), new RequiredFields('point_of_contact_name', 'point_of_contact_email', 'start_date', 'end_date', 'country'))); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * Form used for adding or editing addresses */ public function AddressForm() { $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Checkout.PersonalDetails', 'Personal Details'), 2), TextField::create('FirstName', _t('Checkout.FirstName', 'First Name(s)')), TextField::create('Surname', _t('Checkout.Surname', 'Surname')), CheckboxField::create('Default', _t('Checkout.DefaultAddress', 'Default Address?'))->setRightTitle(_t('Checkout.Optional', 'Optional')))->setName("PersonalFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Checkout.Address', 'Address'), 2), TextField::create('Address1', _t('Checkout.Address1', 'Address Line 1')), TextField::create('Address2', _t('Checkout.Address2', 'Address Line 2'))->setRightTitle(_t('Checkout.Optional', 'Optional')), TextField::create('City', _t('Checkout.City', 'City')), TextField::create('PostCode', _t('Checkout.PostCode', 'Post Code')), CountryDropdownField::create('Country', _t('Checkout.Country', 'Country'))->setAttribute("class", 'countrydropdown dropdown'))->setName("AddressFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $fields = FieldList::create(HiddenField::create("ID"), HiddenField::create("OwnerID"), CompositeField::create($personal_fields, $address_fields)->setName("DeliveryFields")->addExtraClass('line')->addExtraClass('units-row')); $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $this->owner->Link('addresses') . '" class="btn btn-red">' . _t('Checkout.Cancel', 'Cancel') . '</a>'), FormAction::create('doSaveAddress', _t('Checkout.Add', 'Add'))->addExtraClass('btn')->addExtraClass('btn-green')); $validator = RequiredFields::create(array('FirstName', 'Surname', 'Address1', 'City', 'PostCode', 'Country')); $form = Form::create($this->owner, "AddressForm", $fields, $actions, $validator); return $form; }
function RegistrationForm() { // Name Set $FirstNameField = new TextField('FirstName', "First Name"); $LastNameField = new TextField('Surname', "Last Name"); // Email Addresses $PrimaryEmailField = new TextField('Email', "Primary Email Address"); // New Gender Field $GenderField = new OptionSetField('Gender', 'I identify my gender as:', array('Male' => 'Male', 'Female' => 'Female', 'Specify' => 'Let me specify', 'Prefer not to say' => 'Prefer not to say')); $GenderSpecifyField = new TextField('GenderSpecify', 'Specify your gender'); $GenderSpecifyField->addExtraClass('hide'); $StatementOfInterestField = new TextField('StatementOfInterest', 'Statement of Interest'); $StatementOfInterestField->addExtraClass('autocompleteoff'); $affiliations = new FieldGroup(new HeaderField('Affiliations'), new LiteralField("add-affiliation", "<a class='roundedButton' id='add-affiliation' title='Add New Affiliation' href='#'>Add New Affiliation</a>"), new LiteralField("affiliations-container", "<div id='affiliations-container'></div>")); $fields = new FieldList($FirstNameField, $LastNameField, new LiteralField('break', '<hr/>'), $PrimaryEmailField, new LiteralField('instructions', '<p>This will also be your login name.</p>'), new LiteralField('break', '<hr/>'), $GenderField, $GenderSpecifyField, new LiteralField('instructions', '<p>It\'s perfectly acceptable if you choose not to tell us: we appreciate you becoming a member of OpenStack Foundation. The information will remain private and only used to monitor our effort to improve gender diversity in our community.</p>'), new LiteralField('break', '<hr/>'), $affiliations, new HiddenField("Affiliations", "Affiliations", ""), new LiteralField('instructions', '<p>For our purposes, an affiliation is defined as any company where you are an officer, director or employee, or any person or company that has paid you more than $60,000 USD as an independent contractor in the last 12 months. Please list all affiliations which meet this criteria. If you\'re not being paid to work on OpenStack please put "Unaffiliated".</p>'), $StatementOfInterestField, new LiteralField('instructions', '<p>Your statement of interest should be a few words describing your objectives or plans for OpenStack.</p>'), new LiteralField('break', '<hr/>'), new TextField('Address', _t('Addressable.ADDRESS', 'Street Address (Line1)')), new TextField('Suburb', _t('Addressable.SUBURB', 'Street Address (Line2)')), new TextField('City', _t('Addressable.CITY', 'City'))); $label = _t('Addressable.STATE', 'State'); if (is_array($this->allowedStates)) { $fields->push(new DropdownField('State', $label, $this->allowedStates)); } elseif (!is_string($this->allowedStates)) { $fields->push(new TextField('State', $label)); } $AdressField = new TextField('Postcode', _t('Addressable.POSTCODE', 'Postcode')); $fields->push($AdressField); $label = _t('Addressable.COUNTRY', 'Country'); if (is_array($this->allowedCountries)) { $countryField = new DropdownField('Country', $label, $this->allowedCountries); $countryField->addExtraClass('chzn-select'); $countryField->setEmptyString('-- Select One --'); $fields->push($countryField); } elseif (!is_string($this->allowedCountries)) { $countryField = new CountryDropdownField('Country', $label); $countryField->setEmptyString('-- Select One --'); $countryField->addExtraClass('chzn-select'); $fields->push($countryField); } $fields->push(new LiteralField('break', '<hr/>')); $fields->push(new ConfirmedPasswordField('Password', 'Password')); $fields->push(new HiddenField('MembershipType', 'MembershipType', 'foundation')); $actions = new FieldList(new FormAction('doRegister', 'Submit My Application')); $validator = new Member_Validator('FirstName', 'Surname', 'Email', 'StatementOfInterest', 'Address', 'City', 'Country', 'Password'); return new HoneyPotForm($this, 'RegistrationForm', $fields, $actions, $validator); }
/** * getCMSFields * Construct the FieldList used in the CMS. To provide a * smarter UI we don't use the scaffolding provided by * parent::getCMSFields. * * @return FieldList */ public function getCMSFields() { Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css'); /** * In order to keep the automatic construction of the has_one relationship in the backgroud we will make * use of the parent's getCMSFields() and not create our own FieldList as in other models */ $fields = parent::getCMSFields(); //Remove fields $fields->removeFieldsFromTab("Root.Main", array("FirstName", "Surname", "CompanyName", "PhoneNumber", "AddressLine1", "AddressLine2", "City", "StateCounty", "Country", "Postcode", "AddressType", "CustomerID")); $fields->addFieldsToTab("Root.Main", array(HeaderField::create("Add/Edit Address"), CompositeField::create(DropdownField::create("AddressType", "Address Type", array("1" => "Residential", "2" => "Commercial")), TextField::create("FirstName", "First Name"), TextField::create("Surname", "Surname"), TextField::create("CompanyName", "Company Name"), TextField::create("AddressLine1", "Address Line 1"), TextField::create("AddressLine2", "Address Line 2"), TextField::create("City", "Town/City"), TextField::create("StateCounty", "State/County"), TextField::create("Postcode", "Zip/Postcode"), CountryDropdownField::create("Country", "Country"), TextField::create("PhoneNumber", "Contact Number")))); return $fields; }
public function updateCMSFields(FieldList $fields) { /** @var Page|MapaelCountryPageExtension $page */ $page = $this->getOwner(); $labels = $page->fieldLabels(); $name = MapaelCountryPage::create()->i18n_singular_name(); $tab = $fields->findOrMakeTab('Root.CountryPageTab', $name); $tab->push(new TabSet('CountryPageTabSet', $main = new Tab('CountryPageMain', _t('CMSMain.TabContent', 'Content')), $cities = new Tab('CountryPageCities', $page->fieldLabel('MapaelCities')))); $arr = array(); foreach (MapaelMap::getAreasArray() as $code => $attrs) { $arr[$code] = $attrs['tooltip']['content']; } $main->push($dd = new CountryDropdownField('CountryCode', $page->fieldLabel('CountryCode'), $arr, $page->CountryCode)); $dd->setEmptyString(_t(__CLASS__ . '.CountryCodeNone', 'None')); $main->push($tf = self::getTooltipContentField($page)); $tf->setDescription(MapaelMap::getCountryName($page->CountryCode)); $main->push(self::getTargetField($page)); $main->push(self::getHrefField($page)); if ($page->CountryHolderPageID) { $main->push(new ReadonlyField('CountryHolderPageReadonly', $page->fieldLabel('CountryHolderPage'), $page->CountryHolderPage()->Title)); } $cities->push(GridField::create('MapaelCities', $page->fieldLabel('MapaelCities'), $page->MapaelCities(), GridFieldConfig_RelationEditor::create())); }
public function __construct($controller, $name = "BillingDetailsForm") { $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Commerce.PersonalDetails', 'Personal Details'), 3), TextField::create('FirstName', _t('Commerce.FirstName', 'First Name(s)') . '*'), TextField::create('Surname', _t('Commerce.Surname', 'Surname') . '*'), TextField::create("Company", _t('Commerce.Company', "Company")), EmailField::create('Email', _t('Commerce.Email', 'Email') . '*'), TextField::create('PhoneNumber', _t('Commerce.Phone', 'Phone Number')))->setName("PersonalFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Commerce.Address', 'Address'), 3), TextField::create('Address1', _t('Commerce.Address1', 'Address Line 1') . '*'), TextField::create('Address2', _t('Commerce.Address2', 'Address Line 2')), TextField::create('City', _t('Commerce.City', 'City') . '*'), TextField::create('PostCode', _t('Commerce.PostCode', 'Post Code') . '*'), CountryDropdownField::create('Country', _t('Commerce.Country', 'Country') . '*', null, 'GB')->setAttribute("class", 'countrydropdown dropdown btn'))->setName("AddressFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $fields = FieldList::create(CompositeField::create($personal_fields, $address_fields)->setName("BillingFields")->addExtraClass('line')->addExtraClass('units-row')); // Add a save address for later checkbox if a user is logged in if (Member::currentUserID()) { $fields->add(CompositeField::create(CheckboxField::create("SaveAddress", _t('Commerce.SaveAddress', 'Save this address for later')))->setName("SaveAddressHolder")->addExtraClass('line')->addExtraClass('units-row')); } $back_url = Controller::join_links(BASE_URL, ShoppingCart::config()->url_segment); $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('doSetDelivery', _t('Commerce.SetDeliveryAddress', 'Deliver to another address'))->addExtraClass('btn')->addExtraClass('commerce-action-next'), FormAction::create('doContinue', _t('Commerce.DeliverThisAddress', 'Deliver to this address'))->addExtraClass('btn')->addExtraClass('commerce-action-next')->addExtraClass('btn-green')); $validator = new RequiredFields('FirstName', 'Surname', 'Address1', 'City', 'PostCode', 'Country', 'Email'); parent::__construct($controller, $name, $fields, $actions, $validator); }
public function __construct($controller, $name, $type) { /* Fields */ $fields = FieldList::create(DropdownField::create("AddressType", "Address Type", array("1" => "Residential", "2" => "Commercial")), TextField::create("FirstName", "First Name"), TextField::create("Surname", "Surname"), TextField::create("CompanyName", "Company Name"), TextField::create("AddressLine1", "Address Line 1"), TextField::create("AddressLine2", "Address Line 2"), TextField::create("City", "Town/City"), TextField::create("StateCounty", "State/County"), TextField::create("Postcode", "Zip/Postcode"), CountryDropdownField::create("Country", "Country"), TextField::create("PhoneNumber", "Contact Number"), HiddenField::create("Type", "Type", $type)); /* Actions */ $actions = FieldList::create(CompositeField::create(FormAction::create('newaddress', 'Use Address & Continue'))); /* Required Fields */ $required = new RequiredFields(array("FirstName", "Surname", "AddressLine1", "City", "StateCounty", "Country", "Postcode", "AddressType", "PhoneNumber")); /* * Now we create the actual form with our fields and actions defined * within this class. */ return parent::__construct($controller, $name, $fields, $actions, $required); }
public function __construct($controller, $name = "DeliveryDetailsForm") { $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Checkout.PersonalDetails', 'Personal Details'), 3), TextField::create('DeliveryCompany', _t('Checkout.Company', 'Company'))->setRightTitle(_t("Checkout.Optional", "Optional")), TextField::create('DeliveryFirstnames', _t('Checkout.FirstName', 'First Name(s)')), TextField::create('DeliverySurname', _t('Checkout.Surname', 'Surname')))->setName("PersonalFields"); $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Checkout.Address', 'Address'), 3), TextField::create('DeliveryAddress1', _t('Checkout.Address1', 'Address Line 1')), TextField::create('DeliveryAddress2', _t('Checkout.Address2', 'Address Line 2'))->setRightTitle(_t("Checkout.Optional", "Optional")), TextField::create('DeliveryCity', _t('Checkout.City', 'City')), TextField::create('DeliveryPostCode', _t('Checkout.PostCode', 'Post Code')), CountryDropdownField::create('DeliveryCountry', _t('Checkout.Country', 'Country')))->setName("AddressFields"); $fields = FieldList::create(CompositeField::create($personal_fields, $address_fields)->setName("DeliveryFields")->setColumnCount(2)); // Add a save address for later checkbox if a user is logged in if (Member::currentUserID()) { $member = Member::currentUser(); $fields->add(CompositeField::create(CheckboxField::create("SaveAddress", _t('Checkout.SaveAddress', 'Save this address for later')))->setName("SaveAddressHolder")); } $actions = FieldList::create(FormAction::create('doContinue', _t('Checkout.PostageDetails', 'Select Postage'))->addExtraClass('checkout-action-next')); $validator = new RequiredFields('DeliveryFirstnames', 'DeliverySurname', 'DeliveryAddress1', 'DeliveryCity', 'DeliveryPostCode', 'DeliveryCountry'); parent::__construct($controller, $name, $fields, $actions, $validator); $this->setTemplate($this->ClassName); }
public function __construct($controller, $name = "DeliveryDetailsForm") { $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Checkout.PersonalDetails', 'Personal Details'), 3), TextField::create('DeliveryCompany', _t('Checkout.Company', 'Company'))->setRightTitle(_t("Checkout.Optional", "Optional")), TextField::create('DeliveryFirstnames', _t('Checkout.FirstName', 'First Name(s)')), TextField::create('DeliverySurname', _t('Checkout.Surname', 'Surname')))->setName("PersonalFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Checkout.Address', 'Address'), 3), TextField::create('DeliveryAddress1', _t('Checkout.Address1', 'Address Line 1')), TextField::create('DeliveryAddress2', _t('Checkout.Address2', 'Address Line 2'))->setRightTitle(_t("Checkout.Optional", "Optional")), TextField::create('DeliveryCity', _t('Checkout.City', 'City')), TextField::create('DeliveryPostCode', _t('Checkout.PostCode', 'Post Code')), CountryDropdownField::create('DeliveryCountry', _t('Checkout.Country', 'Country')))->setName("AddressFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50'); $fields = FieldList::create(CompositeField::create($personal_fields, $address_fields)->setName("DeliveryFields")->addExtraClass('line')->addExtraClass('units-row')); // Add a save address for later checkbox if a user is logged in if (Member::currentUserID()) { $member = Member::currentUser(); $fields->add(CompositeField::create(CheckboxField::create("SaveAddress", _t('Checkout.SaveAddress', 'Save this address for later')))->setName("SaveAddressHolder")->addExtraClass('line')->addExtraClass('units-row')); } $back_url = $controller->Link(); $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red checkout-action-back">' . _t('Checkout.Back', 'Back') . '</a>'), FormAction::create('doContinue', _t('Checkout.PostageDetails', 'Select Postage'))->addExtraClass('btn')->addExtraClass('checkout-action-next')->addExtraClass('btn-green')); $validator = new RequiredFields('DeliveryFirstnames', 'DeliverySurname', 'DeliveryAddress1', 'DeliveryCity', 'DeliveryPostCode', 'DeliveryCountry'); parent::__construct($controller, $name, $fields, $actions, $validator); }
public function __construct($controller, $name = "BillingDetailsForm") { $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Checkout.PersonalDetails', 'Personal Details'), 3), TextField::create('FirstName', _t('Checkout.FirstName', 'First Name(s)')), TextField::create('Surname', _t('Checkout.Surname', 'Surname')), TextField::create("Company", _t('Checkout.Company', "Company"))->setRightTitle(_t("Checkout.Optional", "Optional")), EmailField::create('Email', _t('Checkout.Email', 'Email')), TextField::create('PhoneNumber', _t('Checkout.Phone', 'Phone Number')))->setName("PersonalFields"); $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Checkout.Address', 'Address'), 3), TextField::create('Address1', _t('Checkout.Address1', 'Address Line 1')), TextField::create('Address2', _t('Checkout.Address2', 'Address Line 2'))->setRightTitle(_t("Checkout.Optional", "Optional")), TextField::create('City', _t('Checkout.City', 'City')), TextField::create('PostCode', _t('Checkout.PostCode', 'Post Code')), CountryDropdownField::create('Country', _t('Checkout.Country', 'Country'), null, 'GB'))->setName("AddressFields"); $fields = FieldList::create($billing_fields = CompositeField::create($personal_fields, $address_fields)->setName("BillingFields")->setColumnCount(2)); // Add a save address for later checkbox if a user is logged in if (Member::currentUserID()) { $fields->add(CompositeField::create(CheckboxField::create("SaveAddress", _t('Checkout.SaveAddress', 'Save this address for later')))->setName("SaveAddressHolder")); } $actions = FieldList::create(); if (ShoppingCart::get()->isCollection()) { $actions->add(FormAction::create('doSetDelivery', _t('Checkout.UseTheseDetails', 'Use these details'))->addExtraClass('checkout-action-next')); } else { $actions->add(FormAction::create('doSetDelivery', _t('Checkout.SetDeliveryAddress', 'Deliver to another address'))->addExtraClass('checkout-action-next')); $actions->add(FormAction::create('doContinue', _t('Checkout.DeliverThisAddress', 'Deliver to this address'))->addExtraClass('checkout-action-next')); } $validator = new RequiredFields('FirstName', 'Surname', 'Address1', 'City', 'PostCode', 'Country', 'Email', 'PhoneNumber'); parent::__construct($controller, $name, $fields, $actions, $validator); $this->setTemplate($this->ClassName); }
/** * @param $field_name * @return mixed */ public function getFieldForName($field_name) { $field_title = preg_replace('/(?<=\\w)(?=[A-Z])/', ' $1', $field_name); switch ($field_name) { case 'Country': $field = CountryDropdownField::create($field_name, $field_title); break; case 'State': $field = class_exists('USStateDropdownField') ? USStateDropdownField::create($field_name, $field_title) : TextField::create($field_name, $field_title); break; case 'Email': $field = EmailField::create($field_name, $field_title); break; case 'MetaType': $field = DropdownField::create('MetaType', 'Meta Type', $this->config()->flexiaddress_metatype); break; default: $field = TextField::create($field_name, $field_title); break; } return $field; }
function __construct($controller, $name) { // Name Set $FirstNameField = new TextField('FirstName', "First Name"); $LastNameField = new TextField('Surname', "Last Name"); // Email Addresses $PrimaryEmailField = new TextField('Email', "Primary Email Address"); $SecondEmailField = new TextField('SecondEmail', "Second Email Address"); $ThirdEmailField = new TextField('ThirdEmail', "Third Email Address"); // Replace Fields $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0); $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0); $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0); // Shirt Size Field $ShirtSizeField = new DropdownField('ShirtSize', 'Choose A Shirt Size', array('Small' => "Men's Small", 'Medium' => "Men's Medium", 'Large' => "Men's Large", 'XL' => "Men's XL", 'XXL' => "Men's XXL", 'WS' => "Womens Small", 'WM' => "Womens Medium", 'WL' => "Womens Large", 'WXL' => "Womens XL", 'WXXL' => 'Womens XXL')); $affiliations = new FieldGroup(new HeaderField('Affiliations'), new LiteralField("add-affiliation", "<a class='roundedButton' id='add-affiliation' title='Add New Affiliation' href='#'>Add New Affiliation</a>"), new LiteralField("affiliations-container", "<div id='affiliations-container'></div>")); $StatementOfInterestField = new TextField('StatementOfInterest', 'Statement of Interest'); $StatementOfInterestField->addExtraClass('autocompleteoff'); // Photo $PhotoField = new CustomUploadField('Photo', 'Photo <em>(Optional)</em>'); $PhotoField->setCanAttachExisting(false); $PhotoField->setAllowedMaxFileNumber(1); $PhotoField->setAllowedFileCategories('image'); $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons'); $PhotoField->setFolderName('profile-images'); $sizeMB = 1; // 1 MB $size = $sizeMB * 1024 * 1024; // 1 MB in bytes $PhotoField->getValidator()->setAllowedMaxFileSize($size); $PhotoField->setCanPreviewFolder(false); // Don't show target filesystem folder on upload field // Biography $BioField = new TextAreaField('Bio', 'Bio: A Little Bit About You <em>(Optional)</em>', 10, 15); // Food Preference $FoodPreferenceField = new CheckboxSetField('FoodPreference', 'Do you have any food preferences we can help accomodate?', array('Vegan' => 'Vegan', 'Vegetarian' => 'Vegetarian', 'Gluten' => 'Gluten allergy', 'Peanut' => 'Peanut allergy')); // Other Field $OtherFoodField = new TextField('OtherFood', 'Other Food Considerations'); $OtherFoodField->addExtraClass('other-field'); // IRC and Twitter $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>'); $TwitterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>'); $LinkedInProfileField = new TextField('LinkedInProfile', 'LinkedIn Profile <em>(Optional)</em>'); // Associated Projects $ProjectsField = new CheckboxSetField('Projects', 'What programs are you involved with? <em>(Optional)</em>', array('Nova' => 'Compute', 'Swift' => 'Object Storage', 'Glance' => 'Image Service', 'Keystone' => 'Identity Service', 'Horizon' => 'Dashboard', 'Quantum' => 'Networking', 'Cinder' => 'Block Storage', 'Ceilometer' => 'Metering/Monitoring', 'Heat' => 'Orchestration', 'Trove' => 'Database Service', 'Ironic' => 'Bare Metal', 'Queue' => 'Queue Service', 'DataProcessing' => 'Data Processing', 'Oslo' => 'Common Libraries', 'Openstack-ci' => 'Infrastructure', 'Openstack-manuals' => 'Documentation', 'QA' => 'Quality Assurance', 'Deployment' => 'Deployment', 'DevStack' => 'DevStack', 'Release' => 'Release Cycle Management')); // Other Projects Field $OtherProjectField = new TextField('OtherProject', 'Other Project (if one above does not match)'); $OtherProjectField->addExtraClass('other-field'); //Newsletter Field $subscribedToNewsletterField = new CheckboxField('SubscribedToNewsletter', 'I don\'t mind occasionally receiving the OpenStack community newsletter.'); $DisplayOnSiteField = new CheckboxField('DisplayOnSite', 'Include this bio on openstack.org.'); // New Gender Field $GenderField = new OptionSetField('Gender', 'I identify my gender as:', array('Male' => 'Male', 'Female' => 'Female', 'Specify' => 'Let me specify', 'Prefer not to say' => 'Prefer not to say')); $GenderSpecifyField = new TextField('GenderSpecify', 'Specify your gender'); $GenderSpecifyField->addExtraClass('hide'); $fields = new FieldList(new LiteralField('header', '<h3 class="section-divider">Public Information</h3>'), new HeaderField("First & Last Name"), $FirstNameField, $LastNameField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, new LiteralField('break', '<hr/>'), $affiliations, new HiddenField("Affiliations", "Affiliations", ""), new LiteralField('instructions', '<p>For our purposes, an affiliation is defined as any company where you are an officer, director or employee, or any person or company that has paid you more than $60,000 USD as an independent contractor in the last 12 months. Please list all affiliations which meet this criteria. If you\'re not being paid to work on OpenStack please put "Unaffiliated".</p>'), new LiteralField('break', '<hr/>'), $StatementOfInterestField, new LiteralField('instructions', '<p>Your statement of interest should be a few words describing your objectives or plans for OpenStack.</p>'), new LiteralField('break', '<hr/>'), $IRCHandleField, $TwitterNameField, $LinkedInProfileField, $BioField, $PhotoField, new LiteralField('break', '<hr/>'), $ProjectsField, $OtherProjectField, new LiteralField('header', '<h3 class="section-divider">Private Information</h3>'), new HeaderField("Email Addresses"), new LiteralField('instructions', '<p class="info"><strong>If you\'re an active developer on the OpenStack project, please list any email addresses you use to commit code.</strong> (This will really help us avoid duplicates!) If you contributed code ONLY using gerrit, all email addresses you used will be listed on the <a href="https://review.openstack.org/#/settings/web-identities" target="_blank">web identities page</a>. If you have contributed also <em>before</em> gerrit was put in place, please make an effort to remember other email addresses you may have used. Interested in how to <a href="http://wiki.openstack.org/HowToContribute" target="_blank">become a contributor</a>?</p>'), $PrimaryEmailField, new LiteralField('instructions', '<p class="info">This email address is also the account name you use to login.</p>'), $SecondEmailField, $ThirdEmailField, new LiteralField('break', '<hr/>'), $GenderField, $GenderSpecifyField, new LiteralField('instructions', '<p>It\'s perfectly acceptable if you choose not to tell us: we appreciate you becoming a member of OpenStack Foundation. The information will remain private and only used to monitor our effort to improve gender diversity in our community.</p>'), new LiteralField('break', '<hr/>'), $FoodPreferenceField, $OtherFoodField, new LiteralField('break', '<hr/>'), $ShirtSizeField, $subscribedToNewsletterField, $DisplayOnSiteField, new LiteralField('break', '<hr/>'), new TextField('Address', _t('Addressable.ADDRESS', 'Street Address (Line1)')), new TextField('Suburb', _t('Addressable.SUBURB', 'Street Address (Line2)')), new TextField('City', _t('Addressable.CITY', 'City'))); // Address Continued $label = _t('Addressable.STATE', 'State'); if (is_array($this->allowedStates)) { $fields->push(new DropdownField('State', $label, $this->allowedStates)); } elseif (!is_string($this->allowedStates)) { $fields->push(new TextField('State', $label)); } $fields->push(new TextField('Postcode', _t('Addressable.POSTCODE', 'Postcode'))); $label = _t('Addressable.COUNTRY', 'Country'); if (is_array($this->allowedCountries)) { $countryField = new DropdownField('Country', $label, $this->allowedCountries); $countryField->setEmptyString('-- Select One --'); $fields->push($countryField); } elseif (!is_string($this->allowedCountries)) { $countryField = new CountryDropdownField('Country', $label); $countryField->setEmptyString('-- Select One --'); $fields->push($countryField); } $fields->push(new LiteralField('break', '<hr/>')); $fields->push(new LiteralField('changepassword', '<a href="/Security/changepassword">Click here to change your password</a>')); // Create action $actions = new FieldList(new FormAction('SaveProfile', 'Save')); // Create validators $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('FirstName', 'Surname', 'StatementOfInterest', 'Address', 'City'), new RequiredFields('Email', 'Country'))); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * Form responsible for estimating shipping based on location and * postal code * * @return Form */ public function PostageForm() { if (!Checkout::config()->simple_checkout) { $available_postage = Session::get("Checkout.AvailablePostage"); // Setup form $form = Form::create($this, 'PostageForm', $fields = new FieldList(CountryDropdownField::create('Country', _t('Checkout.Country', 'Country')), TextField::create("ZipCode", _t('Checkout.ZipCode', "Zip/Postal Code"))), $actions = new FieldList(FormAction::create("doSetPostage", _t('Checkout.Search', "Search"))->addExtraClass('btn')->addExtraClass('btn btn-green btn-success')), $required = RequiredFields::create(array("Country", "ZipCode")))->addExtraClass('forms')->addExtraClass('forms-inline')->setLegend(_t("Checkout.EstimateShipping", "Estimate Shipping")); // If we have stipulated a search, then see if we have any results // otherwise load empty fieldsets if ($available_postage && $available_postage->exists()) { // Loop through all postage areas and generate a new list $postage_array = array(); foreach ($available_postage as $area) { $area_currency = new Currency("Cost"); $area_currency->setValue($area->Cost); $postage_array[$area->ID] = $area->Title . " (" . $area_currency->Nice() . ")"; } $fields->add(OptionsetField::create("PostageID", _t('Checkout.SelectPostage', "Select Postage"), $postage_array)); $actions->dataFieldByName("action_doSetPostage")->setTitle(_t('Checkout.Update', "Update")); } // Check if the form has been re-posted and load data $data = Session::get("Form.{$form->FormName()}.data"); if (is_array($data)) { $form->loadDataFrom($data); } // Check if the postage area has been set, if so, Set Postage ID $data = array(); $data["PostageID"] = Session::get("Checkout.PostageID"); if (is_array($data)) { $form->loadDataFrom($data); } // Extension call $this->extend("updatePostageForm", $form); return $form; } }
public function getCMSFields() { $member = Member::currentUser(); $existing_customer = $this->config()->existing_customer_class; // Manually inject HTML for totals as Silverstripe refuses to // render Currency.Nice any other way. $subtotal_html = '<div id="SubTotal" class="field readonly">'; $subtotal_html .= '<label class="left" for="Form_ItemEditForm_SubTotal">'; $subtotal_html .= _t("Orders.SubTotal", "Sub Total"); $subtotal_html .= '</label>'; $subtotal_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_SubTotal" class="readonly">'; $subtotal_html .= $this->SubTotal->Nice(); $subtotal_html .= '</span></div></div>'; $discount_html = '<div id="Discount" class="field readonly">'; $discount_html .= '<label class="left" for="Form_ItemEditForm_Discount">'; $discount_html .= _t("Orders.Discount", "Discount"); $discount_html .= '</label>'; $discount_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Discount" class="readonly">'; $discount_html .= $this->dbObject("DiscountAmount")->Nice(); $discount_html .= '</span></div></div>'; $postage_html = '<div id="Postage" class="field readonly">'; $postage_html .= '<label class="left" for="Form_ItemEditForm_Postage">'; $postage_html .= _t("Orders.Postage", "Postage"); $postage_html .= '</label>'; $postage_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Postage" class="readonly">'; $postage_html .= $this->Postage->Nice(); $postage_html .= '</span></div></div>'; $tax_html = '<div id="TaxTotal" class="field readonly">'; $tax_html .= '<label class="left" for="Form_ItemEditForm_TaxTotal">'; $tax_html .= _t("Orders.Tax", "Tax"); $tax_html .= '</label>'; $tax_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_TaxTotal" class="readonly">'; $tax_html .= $this->TaxTotal->Nice(); $tax_html .= '</span></div></div>'; $total_html = '<div id="Total" class="field readonly">'; $total_html .= '<label class="left" for="Form_ItemEditForm_Total">'; $total_html .= _t("Orders.Total", "Total"); $total_html .= '</label>'; $total_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Total" class="readonly">'; $total_html .= $this->Total->Nice(); $total_html .= '</span></div></div>'; $fields = new FieldList($tab_root = new TabSet("Root", $tab_main = new Tab('Main', new OrderItemGridField("Items", "", $this->Items(), $config = GridFieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldDeleteAction(), new GridFieldAddOrderItem())), new HeaderField("PostageDetailsHeader", _t("Orders.PostageDetails", "Postage Details")), TextField::create("PostageType"), TextField::create("PostageCost"), TextField::create("PostageTax"), new HeaderField("DiscountDetailsHeader", _t("Orders.DiscountDetails", "Discount")), TextField::create("Discount"), TextField::create("DiscountAmount"), OrderSidebar::create(TextField::create('Status'), DropdownField::create('Action', null, $this->config()->actions), ReadonlyField::create("QuoteNumber", "#")->setValue($this->ID), ReadonlyField::create("Created"), LiteralField::create("SubTotal", $subtotal_html), LiteralField::create("Discount", $discount_html), LiteralField::create("Postage", $postage_html), LiteralField::create("TaxTotal", $tax_html), LiteralField::create("Total", $total_html), TextField::create('PaymentProvider'), TextField::create('PaymentNo'))->setTitle("Details")), $tab_customer = new Tab('Customer', HeaderField::create("BillingDetailsHeader", _t("Orders.BillingDetails", "Customer Details")), TextField::create("Company"), TextField::create("FirstName"), TextField::create("Surname"), TextField::create("Address1"), TextField::create("Address2"), TextField::create("City"), TextField::create("PostCode"), CountryDropdownField::create("Country"), TextField::create("Email"), TextField::create("PhoneNumber")), $tab_delivery = new Tab('Delivery', HeaderField::create("DeliveryDetailsHeader", _t("Orders.DeliveryDetails", "Delivery Details")), TextField::create("DeliveryCompany"), TextField::create("DeliveryFirstnames"), TextField::create("DeliverySurname"), TextField::create("DeliveryAddress1"), TextField::create("DeliveryAddress2"), TextField::create("DeliveryCity"), TextField::create("DeliveryPostCode"), CountryDropdownField::create("DeliveryCountry")))); // Add Sidebar is editable if ($this->canEdit()) { $tab_customer->insertBefore(CustomerSidebar::create(new GridField("ExistingCustomers", "", $existing_customer::get(), $config = GridFieldConfig_Base::create()->addComponents($map_extension = new GridFieldMapExistingAction())))->setTitle("Use Existing Customer"), "BillingDetailsHeader"); if (is_array($this->config()->existing_customer_fields)) { $columns = $config->getComponentByType("GridFieldDataColumns"); if ($columns) { $columns->setDisplayFields($this->config()->existing_customer_fields); } } // Set the record ID $map_extension->setMapFields($this->config()->existing_customer_map); } $tab_main->addExtraClass("order-admin-items"); $tab_customer->addExtraClass("order-admin-customer"); $this->extend("updateCMSFields", $fields); $fields->fieldByName('Root')->addextraClass('orders-root'); return $fields; }
/** * @param boolean $geoDefaults * @return \FieldList */ public function getAddressFields($geoDefaults = true) { $fields = new CompositeField(); $localityValue = $this->owner->Locality; $countryCode = $this->owner->CountryCode; $postalCodeValue = $this->owner->PostalCode; if ((!$localityValue || !$countryCode || !$postalCodeValue) && $geoDefaults) { $addressFromIp = Geocoder::geocodeIp(null, 'city', true); if ($addressFromIp) { if (!$localityValue) { $localityValue = (string) $addressFromIp->getLocality(); } if (!$countryCode) { $countryCode = (string) $addressFromIp->getCountryCode(); } if (!$postalCodeValue) { $postalCodeValue = (string) $addressFromIp->getPostalCode(); } } } $longWidth = 300; $shortWidth = 80; $streetname = new TextField('StreetName', _t('GeoMemberExtension.STREETNAME', 'Street Name'), $this->owner->StreetName); $streetname->setAttribute('placeholder', _t('GeoMemberExtension.STREETNAME', 'Street Name')); $streetname->setTitle(''); $streetname->setAttribute('style', 'width:' . $longWidth . 'px'); $streetnumber = new TextField('StreetNumber', _t('GeoMemberExtension.STREETNUMBER', 'Street Number'), $this->owner->StreetNumber); $streetnumber->setAttribute('placeholder', _t('GeoMemberExtension.STREETNUMBERPLACEHOLDER', 'N°')); $streetnumber->setTitle(''); $streetnumber->setAttribute('style', 'width:' . $shortWidth . 'px'); $fields->push($street = new FieldGroup($streetname, $streetnumber)); $street->setTitle(_t('GeoMemberExtension.STREET', 'Street')); $street->setFieldHolderTemplate('AddressFieldHolder'); $postalCodeClass = 'TextField'; if (class_exists('PostCodeField')) { $postalCodeClass = 'PostCodeField'; } $postcode = new $postalCodeClass('PostalCode', _t('GeoMemberExtension.POSTCODE', 'Postal Code'), $postalCodeValue); $postcode->setAttribute('placeholder', _t('GeoMemberExtension.POSTCODEPLACEHOLDER', 'Postcode')); $postcode->setTitle(''); $postcode->setAttribute('style', 'width:' . $shortWidth . 'px'); $locality = new TextField('Locality', _t('GeoMemberExtension.CITY', 'City'), $localityValue); $locality->setAttribute('placeholder', _t('GeoMemberExtension.CITY', 'City')); $locality->setTitle(''); $locality->setAttribute('style', 'width:' . $longWidth . 'px'); $fields->push($localitygroup = new FieldGroup($postcode, $locality)); $localitygroup->setTitle(_t('GeoMemberExtension.LOCALITY', 'Locality')); $localitygroup->setFieldHolderTemplate('AddressFieldHolder'); // Support some countries administrative areas if ($this->owner->CountryCode == 'FR') { $fields->push(new FrenchDepartmentField()); } if ($this->owner->CountryCode == 'BE') { $fields->push(new BelgianProvinceField()); } $label = _t('GeoMemberExtension.COUNTRY', 'Country'); $fields->push($countrydd = new CountryDropdownField('CountryCode', _t('GeoMemberExtension.COUNTRY', 'Country'), self::getCountryList(), $countryCode)); $countrydd->setEmptyString(''); return $fields; }
function __construct($controller, $name, $article = null, bool $is_manager, $use_actions = true) { $IDField = new HiddenField('newsID'); //madatory fields $HeadlineField = new TextField('headline', 'Headline (150 character max)', '', $maxLength = 150); $HeadlineField->addExtraClass('headline'); $SummaryField = new HtmlEditorField('summary', 'Summary (300 character max)'); $SummaryField->addExtraClass('summary'); $SummaryField->setAttribute('max_chars', 300); $CityField = new TextField('city', 'City'); $StateField = new TextField('state', 'State'); $CountryField = new CountryDropdownField('country', 'Country'); $TagsField = new TextField('tags', 'Tags'); $DateEmbargoField = new TextField('date_embargo', 'Desired release date/time: Time zone is Central Time. Please ensure your release date is in Central Time (<a target="_blank" href="http://www.timeanddate.com/worldclock/converter.html">time converter</a>)'); $DateEmbargoField->addExtraClass('datefield'); if ($is_manager) { $DateExpireField = new TextField('date_expire', 'Expire Date'); $DateExpireField->addExtraClass('datefield'); } $UpdatedField = new DatetimeField_Readonly('date_updated', 'Last Updated'); //$UpdatedField->addExtraClass('inline'); //optional fields $BodyField = new HtmlEditorField('body', 'Body'); $LinkField = new TextField('link', 'Link'); $DocumentField = new CustomUploadField('Document', 'Document'); $DocumentField->addExtraClass('hidden'); $DocumentField->setCanAttachExisting(false); $DocumentField->setAllowedMaxFileNumber(1); $DocumentField->setAllowedFileCategories('doc'); $DocumentField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons'); $DocumentField->setFolderName('news-documents'); $sizeMB = 1; // 1 MB $size = $sizeMB * 1024 * 1024; // 1 MB in bytes $DocumentField->getValidator()->setAllowedMaxFileSize($size); $DocumentField->setCanPreviewFolder(false); // Don't show target filesystem folder on upload field $DocumentField->setRecordClass('File'); $ImageField = new CustomUploadField('Image', 'Image (Max size 2Mb - Suggested size 300x250px)'); $ImageField->setCanAttachExisting(false); $ImageField->setAllowedMaxFileNumber(1); $ImageField->setAllowedFileCategories('image'); $ImageField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons'); $ImageField->setFolderName('news-images'); $ImageField->setRecordClass('BetterImage'); $ImageField->getUpload()->setReplaceFile(false); $ImageField->setOverwriteWarning(false); $sizeMB = 2; // 2 MB $size = $sizeMB * 1024 * 1024; // 2 MB in bytes $ImageField->getValidator()->setAllowedMaxFileSize($size); $ImageField->setCanPreviewFolder(false); // Don't show target filesystem folder on upload field if ($is_manager) { $IsLandscapeField = new CheckboxField('is_landscape', 'Is Banner? (landscape image)'); $IsLandscapeField->addExtraClass('is_landscape'); } if ($article) { $IDField->setValue($article->ID); $HeadlineField->setValue($article->Headline); $SummaryField->setValue($article->Summary); $CityField->setValue($article->City); $StateField->setValue($article->State); $CountryField->setValue($article->Country); $TagsField->setValue($article->getTagsCSV()); if ($article->DateEmbargo) { $DateEmbargoField->setValue(date('m/d/Y g:i a', strtotime($article->DateEmbargo))); } else { $DateEmbargoField->setValue(gmdate('m/d/Y g:i a')); } $UpdatedField->setValue($article->LastEdited); $BodyField->setValue($article->Body); $LinkField->setValue($article->Link); if ($article->DateExpire) { $DateExpireField->setValue(date('m/d/Y g:i a', strtotime($article->DateExpire))); } $IsLandscapeField->setValue($article->IsLandscape); //submitter read only $SubmitterFirstNameField = new ReadonlyField('submitter_first_name', 'First Name'); $SubmitterLastNameField = new ReadonlyField('submitter_last_name', 'Last Name'); $SubmitterEmailField = new ReadonlyField('submitter_email', 'Email'); $SubmitterCompanyField = new ReadonlyField('submitter_company', 'Company'); $SubmitterPhoneField = new ReadonlyField('submitter_phone', 'Phone'); $SubmitterFirstNameField->setValue($article->getSubmitter()->FirstName); $SubmitterLastNameField->setValue($article->getSubmitter()->LastName); $SubmitterEmailField->setValue($article->getSubmitter()->Email); $SubmitterCompanyField->setValue($article->getSubmitter()->Company); $SubmitterPhoneField->setValue($article->getSubmitter()->Phone); } else { // submitter fields $SubmitterFirstNameField = new TextField('submitter_first_name', 'First Name'); $SubmitterLastNameField = new TextField('submitter_last_name', 'Last Name'); $SubmitterEmailField = new TextField('submitter_email', 'Email'); $SubmitterCompanyField = new TextField('submitter_company', 'Company'); $SubmitterPhoneField = new TextField('submitter_phone', 'Phone'); $LinkField->setValue('http://'); } $fields = new FieldList($IDField, $HeadlineField, $SummaryField, $CityField, $StateField, $CountryField, $TagsField, $DateEmbargoField); if ($is_manager) { $fields->push($DateExpireField); $fields->push($UpdatedField); } $fields->push(new LiteralField('clear', '<div class="clear"></div>')); $fields->push($BodyField); $fields->push($LinkField); $fields->push($DocumentField); if ($article) { $image = $article->Image(); $document = $article->Document(); if ($document->exists()) { $fields->push(new LiteralField('image_preview', $document->CMSThumbnail())); } $fields->push(new LiteralField('break', '<br/>')); $fields->push($ImageField); if ($image->exists()) { $ImageField->setValue(null, $article); } } else { $fields->push(new LiteralField('break', '<br/>')); $fields->push($ImageField); } if ($is_manager) { $fields->push($IsLandscapeField); $fields->push(new LiteralField('break', '<br/>')); } $fields->push(new LiteralField('break', '<br/><hr/>')); $fields->push(new LiteralField('title', '<h2>Submitter</h2>')); $fields->push($SubmitterFirstNameField); $fields->push($SubmitterLastNameField); $fields->push($SubmitterEmailField); $fields->push($SubmitterCompanyField); $fields->push($SubmitterPhoneField); // Create action $actions = new FieldList(); $actions->push(new FormAction('saveNewsArticle', 'Save')); $this->addExtraClass('news-registration-form'); parent::__construct($controller, $name, $fields, $actions, $validator = null); }
public function getCMSFields() { $f = parent::getCMSFields(); $f->addFieldToTab('Root.Main', new TextField('WebSiteUrl', 'WebSite Url')); $f->addFieldToTab('Root.Main', new CheckboxField('DisplayOnSite', 'Should Display On Site')); $f->addFieldToTab('Root.Main', $messageField = new TextField('LocationMessage', 'Message to display for this location')); $messageField->setAttribute('style', 'max-width:100% !important'); $f->addFieldToTab('Root.Main', new CheckboxField('DetailsPage', 'Send people to a details page first?')); $f->addFieldsToTab("Root.Location", array(HiddenField::create("Lat"), HiddenField::create("Lng"), TextField::create("Address1"), TextField::create("Address2"), TextField::create("ZipCode"), TextField::create("City"), TextField::create("State"), CountryDropdownField::create("Country"), GoogleMapField::create("Map", array("height" => "500px", "width" => "600px", "lng_field" => "Form_ItemEditForm_Lng", "lat_field" => "Form_ItemEditForm_Lat", "address_field" => array('address1' => "Address1", 'zip_code' => "ZipCode", 'city' => "City", 'state' => "State", 'country' => "Country"), 'start_lat' => $this->Lat, 'start_lng' => $this->Lng)))); if ($this->ID > 0) { $config = GridFieldConfig_RecordEditor::create(); $gridField = new GridField('Maps', 'Maps', $this->Maps(), $config); $config->addComponent($sort = new GridFieldSortableRows('Order')); $f->addFieldToTab('Root.Maps', $gridField); } return $f; }
/** * Form responsible for estimating shipping based on location and * postal code * * @return Form */ public function PostageForm() { $available_postage = Session::get("Commerce.AvailablePostage"); // Setup default postage fields $country_select = CompositeField::create(CountryDropdownField::create('Country', _t('Commerce.Country', 'Country'))->setAttribute("class", 'countrydropdown dropdown btn'), TextField::create("ZipCode", _t('Commerce.ZipCode', "Zip/Postal Code")))->addExtraClass("size1of2")->addExtraClass("unit")->addExtraClass("unit-50"); // If we have stipulated a search, then see if we have any results // otherwise load empty fieldsets if ($available_postage) { $search_text = _t('Commerce.Update', "Update"); // Loop through all postage areas and generate a new list $postage_array = array(); foreach ($available_postage as $area) { $area_currency = new Currency("Cost"); $area_currency->setValue($area->Cost); $postage_array[$area->ID] = $area->Title . " (" . $area_currency->Nice() . ")"; } $postage_select = CompositeField::create(OptionsetField::create("PostageID", _t('Commerce.SelectPostage', "Select Postage"), $postage_array))->addExtraClass("size1of2")->addExtraClass("unit")->addExtraClass("unit-50"); $confirm_action = CompositeField::create(FormAction::create("doSavePostage", _t('Commerce.Confirm', "Confirm"))->addExtraClass('btn')->addExtraClass('btn-green'))->addExtraClass("size1of2")->addExtraClass("unit")->addExtraClass("unit-50"); } else { $search_text = _t('Commerce.Search', "Search"); $postage_select = CompositeField::create()->addExtraClass("size1of2")->addExtraClass("unit")->addExtraClass("unit-50"); $confirm_action = CompositeField::create()->addExtraClass("size1of2")->addExtraClass("unit")->addExtraClass("unit-50"); } // Set search field $search_action = CompositeField::create(FormAction::create("doGetPostage", $search_text)->addExtraClass('btn'))->addExtraClass("size1of2")->addExtraClass("unit")->addExtraClass("unit-50"); // Setup fields and actions $fields = new FieldList(CompositeField::create($country_select, $postage_select)->addExtraClass("line")->addExtraClass("units-row-end")); $actions = new FieldList(CompositeField::create($search_action, $confirm_action)->addExtraClass("line")->addExtraClass("units-row-end")); $required = RequiredFields::create(array("Country", "ZipCode")); $form = Form::create($this, 'PostageForm', $fields, $actions, $required)->addExtraClass('forms')->addExtraClass('forms-columnar'); // Check if the form has been re-posted and load data $data = Session::get("Form.{$form->FormName()}.data"); if (is_array($data)) { $form->loadDataFrom($data); } // Check if the postage area has been set, if so, Set Postage ID $data = array(); $data["PostageID"] = Session::get("Commerce.PostageID"); if (is_array($data)) { $form->loadDataFrom($data); } // Extension call $this->extend("updatePostageForm", $form); return $form; }
/** * Constructs a FieldList for use in the CMSForm. * * @return FieldList */ public function construct_cms_fields() { //Create the FieldList and push the Root TabSet on to it. $fields = FieldList::create($root = TabSet::create('Root', Tabset::create("Settings", Tabset::create("General", Tab::create("StoreSettings", HeaderField::create("Maintenance Mode"), CompositeField::create(DropdownField::create("StoreSettings_StoreAvailable", "Store Status", array("1" => "Live", "2" => "Down for Maintenance (show the below message)")), TextareaField::create("StoreSettings_StoreAvailableMessage", "Maintenance Message")->setRightTitle("The message to display to visitors whilst your store is in maintenance mode.")), HeaderField::create("Store Details"), CompositeField::create(TextField::create("StoreSettings_StoreName", "Store Name")->setRightTitle("i.e. Steve's Shoe Shop."), TextareaField::create("StoreSettings_StoreAddress", "Store Address")->setRightTitle("<strong>Example</strong><br />123 ACME Drive<br />Enfield<br />London</br />EN1 1YQ"), CountryDropdownField::create("StoreSettings_StoreCountry", "Store Country")), HeaderField::create("Product Measurements"), CompositeField::create(DropdownField::create("StoreSettings_ProductWeight", "Product Weight", array("Pounds" => "Pounds", "Ounces" => "Ounces", "Grams" => "Grams", "Kilograms" => "Kilograms", "Tonns" => "Tonns"))->setRightTitle("Select the weight measurement you wish to use in your store."), DropdownField::create("StoreSettings_ProductDimensions", "Product Dimensions", array("Inches" => "Inches", "Millimetres" => "Millimetres", "Centimetres" => "Centimetres"))->setRightTitle("Select the width, height and length measurement you wish to use in your store.")), HeaderField::create("SSL"), CompositeField::create(LiteralField::create("SSL_LiteralField", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message warning\">\n\t\t\t\t\t\t\t\t\t\t\t<strong>IMPORTANT:</strong><br />\n\t\t\t\t\t\t\t\t\t\t\tIn order to protect your customers personally identifiable information it is\n\t\t\t\t\t\t\t\t\t\t\tstrongly recommended that you consider installing an SSL certificate for your website.\n\t\t\t\t\t\t\t\t\t\t\t<br />If you are unsure on how to do this please reach out to the party responsible\n\t\t\t\t\t\t\t\t\t\t\tfor this website. \n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tEnabling the option below will ensure all communications between third-party providers\n\t\t\t\t\t\t\t\t\t\tare transmitted over the https:// protocol.\n\t\t\t\t\t\t\t\t\t</div>"), CheckboxField::create("StoreSettings_SSLToggle", "Yes, I have SSL enabled."))), Tab::create("DisplaySettings", HeaderField::create("General Display Settings"), CompositeField::create(NumericField::create("DisplaySettings_FeaturedProducts", "Featured Products")->setRightTitle("Enter the number of products you wish to display in the Featured Products panels."), NumericField::create("DisplaySettings_NewProducts", "New Products")->setRightTitle("Enter the number of products you wish to display in the New Products panels."), DropdownField::create("DisplaySettings_CartQuantity", "Cart Quantity Selection", array("1" => "Dropdown", "2" => "Textbox"))->setRightTitle("Select how you wish the quantity selector to be shown on the product pages.")), HeaderField::create("Product Display Settings"), CompositeField::create(CheckboxField::create("DisplaySettings_ShowPrice", "Show product prices im my store."), CheckboxField::create("DisplaySettings_ShowSKU", "Show product SKUs in my store."), CheckboxField::create("DisplaySettings_ShowWeight", "Show product weights in my store."), CheckboxField::create("DisplaySettings_ShowDimensions", "Show product dimensions in my store."), DropdownField::create("DisplaySettings_ProductSort", "Default Product Sort", array("Title ASC" => "Product Name Ascending", "Title DESC" => "Product Name Descending", "SalePrice ASC, RegularPrice ASC" => "Price Lowest to Highest", "SalePrice DESC, RegularPrice DESC" => "Price Highest to Lowest", "Created ASC" => "Oldest First", "Created DESC" => "Newest First"))), HeaderField::create("Product Photo Display Settings"), CompositeField::create(LiteralField::create("ProductPagePhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Product Page Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for the main photo on a product page.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductPagePhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductPagePhotoHeight", "Width (pixels)")), LiteralField::create("ProductThumbnailPhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Product Thumbnail Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for product thumbnails throughout the store.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductThumbnailPhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductThumbnailPhotoHeight", "Height (pixels)")), LiteralField::create("ProductEnlargedPhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Enlarged Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for enlarged photos. Users will see this if they click\n\t\t\t\t\t\t\t\t\t\tto see the larger version of a product photo from a product page.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductEnlargedPhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductEnlargedPhotoHeight", "Height (pixels)"))))), Tabset::create("Orders", Tab::create("CheckoutSettings", HeaderField::create("Initial Order Status"), CompositeField::create(DropdownField::create("CheckoutSettings_InitialStatus", "Status", DataObject::get("Order_Statuses", "", "Title ASC")->map('ID', 'Title'))->setRightTitle("Select the status you wish all new orders to be set to.")), HeaderField::create("Guest Checkout"), CompositeField::create(CheckboxField::create("CheckoutSettings_GuestCheckout", "Allow customers to checkout as a guest without the need for an account."), CheckboxField::create("CheckoutSettings_GuestCheckoutAccount", "Create an account for customers if they checkout as a guest (if they do not already have one)")), HeaderField::create("Order Comments"), CompositeField::create(CheckboxField::create("CheckoutSettings_OrderComments", "Allow customers to provide a comment with their orders.")), HeaderField::create("Terms & Conditions"), CompositeField::create(CheckboxField::create("CheckoutSettings_TermsAndConditions", "I require my customers to have agreed to terms and conditions before they can place an order."), TreeDropdownField::create("CheckoutSettings_TermsAndConditionsSiteTree", "Terms & Conditions Page", "SiteTree"))), Tab::create("Order Statuses", HeaderField::create("Custom Order Statuses"), CompositeField::create(LiteralField::create("CustomOrderStatus_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis section allows you to specify custom order statuses where those out of the box\n\t\t\t\t\t\t\t\t\t\tdo not otherwise match your businesses requirements.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("CustomOrderStatus", "", DataObject::get("Order_Statuses", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Order Statuses"), CompositeField::create(LiteralField::create("DefaultOrderStatus_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis section displays the default order statuses that are used throughout the store. Feel free\n\t\t\t\t\t\t\t\t\t\tto alter their Display Name and Descriptions to suit the needs of your business.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("DefaultOrderStatus", "", DataObject::get("Order_Statuses", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("EmailNotifications", HeaderField::create("Send store emails from"), CompositeField::create(EmailField::create("EmailNotification_SendEmailsFrom", "From Email Address")->setRightTitle("\n\t\t\t\t\t\t\t\t\tThis is the address that is used in the 'From' section of all automatically generated emails.<br />\n\t\t\t\t\t\t\t\t\t<strong>SMTP Users:</strong> If you are using a SilverStripe SMTP module it is strongly recommended\n\t\t\t\t\t\t\t\t\tyou set this value to that of the authenticated SMTP email address.")), HeaderField::create("New order notifications"), CompositeField::create(EmailField::create("EmailNotification_AdminNewOrder", "Admin Notification Email")->setRightTitle("When the store receives a new order send a notification to the above address.")), HeaderField::create("Send the customer an email when"), CompositeField::create(CheckboxField::create("EmailNotification_AccountCreated", "They create an account."), CheckboxField::create("EmailNotification_OrderPlaced", "They place an order with my store.")), HeaderField::create("Send the customer an email when their order status changes to"), CompositeField::create(CheckboxSetField::create("EmailNotification_OrderStatuses", "Pick your desired statuses", DataObject::get("Order_Statuses", "", "Title ASC")->map('ID', 'Title'))))), Tab::create("Stock", HeaderField::create("Stock Management"), CompositeField::create(LiteralField::create("StockManagement_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t<strong>What is Stock Management?</strong><br />\n\t\t\t\t\t\t\t\t\tStock management is designed to keep tabs on your stock levels. If enabled, stock levels will be\n\t\t\t\t\t\t\t\t\tmanaged by the store and automatically decremented upon receiving a successful order.<br />\n\t\t\t\t\t\t\t\t\tIt will also prevent customers from placing an order for a product if it is deemed to\n\t\t\t\t\t\t\t\t\tbe out of stock.\n\t\t\t\t\t\t\t\t</div>"), CheckboxField::create("Stock_StockManagement", "Enable stock control in my store.")), HeaderField::create("Pending Orders"), CompositeField::create(LiteralField::create("PendingOrders_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tEnter the number of minutes that stock allocated to unpaid orders will be held before the \n\t\t\t\t\t\t\t\t\tassociated order is cancelled and held stock is made available to other customers.\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("Stock_PendingOrdersFreezeStock", ""))), HeaderField::create("Stock Levels"), CompositeField::create(FieldGroup::create(NumericField::create("Stock_LowStockThreshold", "Low Stock Threshold")->setRightTitle("The stock level considered as low."), NumericField::create("Stock_OutOfStockThreshold", "Out of Stock Threshold")->setRightTitle("The stock level considered as out of stock."), TextField::create("Stock_OutofStockMessage", "Out of Stock Message")->setRightTitle("The message to display when a product is out of stock.")), DropdownField::create("Stock_ProductOutOfStock", "Product Out of Stock", array("1" => "Completely hide the product from my store", "2" => "Hide the product but allow the product page to be accessed from its URL", "3" => "Do not make any changes"))->setRightTitle("Select what you wish to happen when a product is out of stock."), DropdownField::create("Stock_StockLevelDisplay", "Stock Level Display", array("1" => "Always show stock levels", "2" => "Show stock levels after the product drops below the low stock threshold", "3" => "Never show stock levels"))->setRightTitle("Select how you would like stock levels to appear in your store."))), Tab::create("Couriers", HeaderField::create("Couriers"), CompositeField::create(GridField::create("CourierSettings", "", DataObject::get("Courier", "", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("Gateways", HeaderField::create("Gateways"), CompositeField::create(GridField::create("GatewaySettings", "", DataObject::get("Gateway", "", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("Currency", HeaderField::create("Accepted Currencies"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\tYou can define additional currencies in this section. Customers will be shown prices in their\n\t\t\t\t\t\t\t\t\tselected currency throughout the store but will transact in your local currency.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CurrencySettings_AcceptedCurrencies", "", DataObject::get("StoreCurrency", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Local (Default) Currency"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\tConfigure your store's local (default) currency in this section.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CurrencySettings_LocalCurrency", "", DataObject::get("StoreCurrency", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tabset::create("Tax", Tab::create("TaxSettings", HeaderField::create("Tax Settings"), CompositeField::create(DropdownField::create("TaxSettings_InclusiveExclusive", "Product Prices Are", array("1" => "Inclusive of Tax", "2" => "Exclusive of Tax")), DropdownField::create("TaxSettings_ShippingInclusiveExclusive", "Shipping Prices Are", array("1" => "Inclusive of Tax", "2" => "Exclusive of Tax")), DropdownField::create("TaxSettings_CalculateUsing", "Calculate Tax Using", array("1" => "Billing Address", "2" => "Shipping Address", "3" => "Store Address")))), Tab::create("TaxClasses", HeaderField::create("Other Tax Classes"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tA Tax class allows you to define tax categories.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ClassesOther", "", DataObject::get("TaxClasses", "(0=SystemCreated)", "ID ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Tax Classes"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThese are the default tax classes.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ClassesDefault", "", DataObject::get("TaxClasses", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("TaxZones", HeaderField::create("Other Tax Zones"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tA Tax Zone allows you to define Tax rules on a country by country basis.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_Zones", "", DataObject::get("TaxZones", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Tax Zone"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis is the default tax zone applies where no zone exists for a customers' country.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ZonesDefault", "", DataObject::get("TaxZones", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction"))))), Tab::create("Reviews", HeaderField::create("Product Reviews"), CompositeField::create(CheckboxField::create("ProductReviewSettings_EnableReviews", "Enable product reviews in my store."), CheckboxField::create("ProductReviewSettings_ApprovedPurchaserOnly", "Require a customer to have purchased an item before making a review."), CheckboxField::create("ProductReviewSettings_AdminApproval", "Require admin approval before reviews are made visible."))))), HiddenField::create('ID', false, 0)); //Tab nav in CMS is rendered through separate template $root->setTemplate('CMSTabSet'); return $fields; }
function MobileRegistrationForm($membership) { //Membership $membershipField = new HiddenField('MembershipType', null, $membership); // Name Set $FirstNameField = new TextField('FirstName', "First Name"); $LastNameField = new TextField('Surname', "Last Name"); // Country $label = _t('Addressable.COUNTRY', 'Country'); $countryField = new CountryDropdownField('Country', $label); $countryField->setEmptyString('-- Select One --'); $countryField->addExtraClass('chzn-select'); // Email Addresses $PrimaryEmailField = new TextField('Email', "Primary Email Address"); $fields = new FieldList($membershipField, $FirstNameField, $LastNameField, $countryField, new LiteralField('break', '<hr/>'), $PrimaryEmailField, new LiteralField('login_text', '<div class="login_lit"> You will use this to login. </div>')); $fields->push(new ConfirmedPasswordField('Password', 'Password')); $actions = new FieldList(new FormAction('doRegisterMobile', 'Complete Registration')); $validator = new Member_Validator('FirstName', 'Surname', 'Email', 'Country', 'Password'); $form = new HoneyPotForm($this, 'MobileRegistrationForm', $fields, $actions, $validator); if ($data = Session::get("FormInfo.{$form->FormName()}.data")) { return $form->loadDataFrom($data); } return $form; }
/** * Create form fields to represent all of the properties on the {@link Omnipay\Common\CreditCard} object. * The form fields are split up into relevent sections to help with adding/removing fields as needed. * * @return FieldList */ protected function getCreditCardFields() { $fields = new FieldList(); $tabindex = 1; // Create personal detail fields $firstNameTextField = new TextField('FirstName', _t('OmnipayableForm.FIRSTNAME', 'First name')); $firstNameTextField->setAttribute('tabindex', $tabindex++); $lastNameTextField = new TextField('LastName', _t('OmnipayableForm.LASTNAME', 'Last name')); $lastNameTextField->setAttribute('tabindex', $tabindex++); $companyTextField = new TextField('Company', _t('OmnipayableForm.COMPANY', 'Company')); $companyTextField->setAttribute('tabindex', $tabindex++); $emailEmailField = new EmailField('Email', _t('OmnipayableForm.EMAIL', 'Email')); $emailEmailField->setAttribute('tabindex', $tabindex++); // Create personal details group $personalFieldGroup = new FieldGroup(); $personalFieldGroup->setName('PersonalDetails'); $personalFieldGroup->setTitle(_t('OmnipayableForm.PERSONALDETAILS', 'Personal Detials')); // Add basic fields to personal details group $personalFieldGroup->push($firstNameTextField); $personalFieldGroup->push($lastNameTextField); $personalFieldGroup->push($companyTextField); $personalFieldGroup->push($emailEmailField); // Add personal details group to fields $fields->push($personalFieldGroup); // Create credit card detail fields $numberCreditCardField = new CreditCardField('Number', _t('OmnipayableForm.NUMBER', 'Card number')); $numberCreditCardField->setAttribute('tabindex', $tabindex++); $cvvTextField = new TextField('Cvv', _t('OmnipayableForm.CVV', 'Security number')); $cvvTextField->setAttribute('tabindex', $tabindex += 3); $expiryMonthDropdownField = new DropdownField('ExpiryMonth', _t('OmnipayableForm.EXPIRYMONTH', 'Expiry month'), $this->getMonths()); $expiryMonthDropdownField->setAttribute('tabindex', $tabindex++); $expiryMonthDropdownField->setHasEmptyDefault(true); $expiryYearDropdownField = new DropdownField('ExpiryYear', _t('OmnipayableForm.EXPIRYYEAR', 'Expiry year'), $this->getYears(20)); $expiryYearDropdownField->setAttribute('tabindex', $tabindex++); $expiryYearDropdownField->setHasEmptyDefault(true); $startMonthDropdownField = new DropdownField('StartMonth', _t('OmnipayableForm.STARTMONTH', 'Start month'), $this->getMonths()); $startMonthDropdownField->setAttribute('tabindex', $tabindex++); $startMonthDropdownField->setHasEmptyDefault(true); $startYearDropdownField = new DropdownField('StartYear', _t('OmnipayableForm.STARTYEAR', 'Start year'), $this->getYears(-20)); $startYearDropdownField->setAttribute('tabindex', $tabindex++); $startYearDropdownField->setHasEmptyDefault(true); $issueNumberTextField = new TextField('IssueNumber', _t('OmnipayableForm.ISSUENUMBER', 'Issue number')); $issueNumberTextField->setAttribute('tabindex', $tabindex++); $typeDropdownField = new DropdownField('Type', _t('OmnipayableForm.TYPE', 'Card type'), $this->getCreditCardTypes()); $typeDropdownField->setAttribute('tabindex', $tabindex++); $typeDropdownField->setHasEmptyDefault(true); $expiryDateFieldGroup = new FieldGroup(); $expiryDateFieldGroup->push($expiryMonthDropdownField); $expiryDateFieldGroup->push($expiryYearDropdownField); $startDateFieldGroup = new FieldGroup(); $startDateFieldGroup->push($startMonthDropdownField); $startDateFieldGroup->push($startYearDropdownField); // Create credit card details group $creditCardFieldGroup = new FieldGroup(); $creditCardFieldGroup->setName('CardDetails'); $creditCardFieldGroup->setTitle(_t('OmnipayableForm.CREDITCARDDETAILS', 'Card Detials')); // Add credit card fields to credit card details group $creditCardFieldGroup->push($numberCreditCardField); $creditCardFieldGroup->push($cvvTextField); $creditCardFieldGroup->push($expiryDateFieldGroup); $creditCardFieldGroup->push($startDateFieldGroup); $creditCardFieldGroup->push($issueNumberTextField); $creditCardFieldGroup->push($typeDropdownField); // Add credit card details group to fields $fields->push($creditCardFieldGroup); // Create billing address fields $billingAddress1TextField = new TextField('BillingAddress1', _t('OmnipayableForm.BILLINGADDRESS1', 'Address 1')); $billingAddress1TextField->setAttribute('tabindex', $tabindex++); $billingAddress2TextField = new TextField('BillingAddress2', _t('OmnipayableForm.BILLINGADDRESS2', 'Address 2')); $billingAddress2TextField->setAttribute('tabindex', $tabindex++); $billingCity = new TextField('BillingCity', _t('OmnipayableForm.BILLINGCITY', 'City')); $billingCity->setAttribute('tabindex', $tabindex++); $billingPostcode = new TextField('BillingPostcode', _t('OmnipayableForm.BILLINGPOSTCODE', 'Postcode')); $billingPostcode->setAttribute('tabindex', $tabindex++); $billingState = new TextField('BillingState', _t('OmnipayableForm.BILLINGSTATE', 'State')); $billingState->setAttribute('tabindex', $tabindex++); $billingCountry = new CountryDropdownField('BillingCountry', _t('OmnipayableForm.BILLINGCOUNTRY', 'Country')); $billingCountry->setAttribute('tabindex', $tabindex++); $billingPhone = new PhoneNumberField('BillingPhone', _t('OmnipayableForm.BILLINGPHONE', 'Phone')); $billingPhone->setAttribute('tabindex', $tabindex++); // Create billing details group $billingFieldGroup = new FieldGroup(); $billingFieldGroup->setName('BillingAddress'); $billingFieldGroup->setTitle(_t('OmnipayableForm.BILLING', 'Billing Address')); // Add billiing fields to billing group $billingFieldGroup->push($billingAddress1TextField); $billingFieldGroup->push($billingAddress2TextField); $billingFieldGroup->push($billingCity); $billingFieldGroup->push($billingPostcode); $billingFieldGroup->push($billingState); $billingFieldGroup->push($billingCountry); $billingFieldGroup->push($billingPhone); // Add billing details group to fields $fields->push($billingFieldGroup); // Create shipping address fields $shippingAddress1TextField = new TextField('ShippingAddress1', _t('OmnipayableForm.SHIPPINGADDRESS1', 'Address 1')); $shippingAddress1TextField->setAttribute('tabindex', $tabindex++); $shippingAddress2TextField = new TextField('ShippingAddress2', _t('OmnipayableForm.SHIPPINGADDRESS2', 'Address 2')); $shippingAddress2TextField->setAttribute('tabindex', $tabindex++); $shippingCity = new TextField('ShippingCity', _t('OmnipayableForm.SHIPPINGCITY', 'City')); $shippingCity->setAttribute('tabindex', $tabindex++); $shippingPostcode = new TextField('ShippingPostcode', _t('OmnipayableForm.SHIPPINGPOSTCODE', 'Postcode')); $shippingPostcode->setAttribute('tabindex', $tabindex++); $shippingState = new TextField('ShippingState', _t('OmnipayableForm.SHIPPINGSTATE', 'State')); $shippingState->setAttribute('tabindex', $tabindex++); $shippingCountry = new CountryDropdownField('ShippingCountry', _t('OmnipayableForm.SHIPPINGCOUNTRY', 'Country')); $shippingCountry->setAttribute('tabindex', $tabindex++); $shippingPhone = new PhoneNumberField('ShippingPhone', _t('OmnipayableForm.SHIPPINGPHONE', 'Phone')); $shippingPhone->setAttribute('tabindex', $tabindex++); // Create shipping details group $shippingFieldGroup = new FieldGroup(); $shippingFieldGroup->setName('ShippingAddress'); $shippingFieldGroup->setTitle(_t('OmnipayableForm.SHIPPING', 'Shipping Address')); // Add billiing fields to shipping group $shippingFieldGroup->push($shippingAddress1TextField); $shippingFieldGroup->push($shippingAddress2TextField); $shippingFieldGroup->push($shippingCity); $shippingFieldGroup->push($shippingPostcode); $shippingFieldGroup->push($shippingState); $shippingFieldGroup->push($shippingCountry); $shippingFieldGroup->push($shippingPhone); // Add shipping details group to fields $fields->push($shippingFieldGroup); return $fields; }
public function getCountriesDDL($id = "add-datacenter-location-country") { $ddl = new CountryDropdownField($id, 'Country'); $ddl->setEmptyString('-- select a country --'); $ddl->addExtraClass('add-control'); $ddl->addExtraClass('countries-ddl'); return $ddl; }
public function getCountriesDDL() { $ddl = new CountryDropdownField('country', 'country'); $ddl->setEmptyString('-- select a country --'); $ddl->addExtraClass('add-control'); $ddl->addExtraClass('countries-ddl'); return $ddl; }