public function __construct($controller, $name = "SetLocationForm") { $countries = SiteConfig::current_site_config()->getCountriesList(); $fields = new FieldList($countryfield = new DropdownField("Country", _t('SetLocationForm.COUNTRY', 'Country'), $countries)); $countryfield->setHasEmptyDefault(true); $countryfield->setEmptyString(_t('SetLocationForm.CHOOSECOUNTRY', 'Choose country...')); $actions = new FieldList(new FormAction("setLocation", "set")); parent::__construct($controller, $name, $fields, $actions); //load currently set location if ($location = ShopUserInfo::singleton()->getLocation()) { $countryfield->setHasEmptyDefault(false); $this->loadDataFrom($location); } }
public function getCMSFields() { $fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true)); $fields->insertAfter(new ReadonlyField('Type'), 'Title'); $fields->removeByName('ListID'); $fields->removeByName('ParentID'); $fields->removeByName('Sort'); $fields->removeByName('ExtraClass'); /** Title * By default, the Title is used for reference only * Set $enable_title_in_template to true when using title in template */ if (!$this->enable_title_in_template) { $fields->removeByName('HideTitle'); $title = $fields->fieldByName('Root.Main.Title'); if ($title) { $title->setRightTitle('For reference only. Does not appear in the template.'); } } $fields->addFieldToTab('Root.Settings', new TextField('ExtraClass', 'Extra CSS Classes to add')); if (!is_a($this, 'ElementList')) { $lists = ElementList::get()->filter('ParentID', $this->ParentID); if ($lists->exists()) { $fields->addFieldToTab('Root.Main', $move = new DropdownField('MoveToListID', 'Move this to another list', $lists->map('ID', 'CMSTitle'), '')); $move->setEmptyString('Select a list..'); $move->setHasEmptyDefault(true); } } $this->extend('updateCMSFields', $fields); return $fields; }
public function testHasEmptyDefault() { $source = array(1 => 'one'); $field = new DropdownField('Field', null, $source); $field->setHasEmptyDefault(true); $this->assertEquals($field->getSource(), array('' => '', 1 => 'one')); }
/** * @return Form */ public function AddForm() { $fields = new FieldList(new LiteralField('SelectFieldType', '<p><strong>Please select a field type to add:</strong></p>'), $df = new DropdownField('ClassName', '', $this->getFieldTypes(), null, null)); $df->setHasEmptyDefault(true); if ($schemaID = (int) $this->request->param('ID')) { $fields->push(new HiddenField('SchemaID', '', $schemaID)); } $actions = new FieldList(FormAction::create('doAddField', 'Create')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); // Add a Cancel link which is a button-like link and link back to one level up. $curmbs = $this->Breadcrumbs(); if ($curmbs && $curmbs->count() >= 2) { $one_level_up = $curmbs->offsetGet($curmbs->count() - 2); $text = "\n\t\t\t<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"" . $one_level_up->Link . "\">\n\t\t\t\tCancel\n\t\t\t</a>"; $actions->push(new LiteralField('cancelbutton', $text)); } $form = new Form($this, 'AddForm', $fields, $actions); $toplevelController = $this->getToplevelController(); $form->setTemplate('LeftAndMain_EditForm'); $form->addExtraClass('cms-content cms-edit-form center ss-tabset stacked'); $form->setAttribute('data-pjax-fragment', 'CurrentForm Content'); if ($form->Fields()->hasTabset()) { $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); } //var_dump($this->popupController); die; $parents = $this->popupController->Breadcrumbs(false)->items; $form->Backlink = array_pop($parents)->Link; return $form; }
/** * Adds a field the the cms allowing the user to choose a secondary identifier based on templates * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { /** @var Config_ForClass $config */ $config = $this->owner->config(); $fields->replaceField('SecondaryIdentifier', $field = new DropdownField('SecondaryIdentifier', 'Secondary Identifier', $this->getAvailableSecondaryIdentifiers($config->get('secondaryIdentifierAsTemplatesMap', Config::UNINHERITED)))); if (Config::inst()->forClass(__CLASS__)->get('HasDefault')) { $field->setHasEmptyDefault(true); $field->setEmptyString('Default'); } }
/** * Overwrites SiteTree.getCMSFields. * * * @codeCoverageIgnore * * @return fieldset */ function getCMSFields() { $fields = parent::getCMSFields(); $maps = DataObject::get("OLMapObject"); $items = array(); // get all assigned agent-members if ($maps) { // get first member (agents) $items = $maps->map('ID', 'Title'); } $MapDropdownField = new DropdownField("MapID", "Map", $items, $this->MapID, null); $MapDropdownField->setHasEmptyDefault(true); $fields->addFieldsToTab("Root.Main", array(new LiteralField("MapLabel", "<h2>Map Selection</h2>"), new CompositeField(new CompositeField(new LiteralField("DefLabel", "<h3>Default OpenLayers Map</h3>"), $MapDropdownField)))); return $fields; }
function Form() { $isRunning = Session::get('db'); if ($isRunning) { $actions = new FieldSet(new FormAction('endsession', 'End Session')); } else { $actions = new FieldSet(new FormAction('startsession', 'Start Session')); } $form = new Form($this, 'Form', new FieldSet(new HeaderField('Header1', $isRunning ? 'Session is already running' : 'Start new regress session'), new LiteralField('Lit1', '<p>Use this form to set configuration prior to starting a <a href="http://regress.silverstripe.com">regress.silverstripe.com</a> test session (manual testing).</p>'), $dbField = new DropdownField('db', 'Database', array('mysql' => 'MySQL', 'postgresql' => 'Postgres', 'mssql' => 'MSSQL', 'sqlite3' => 'SQLite3'), Session::get('db')), $chkField = new CheckboxField('enabletranslatable', 'Translatable?', Session::get('enabletranslatable'))), $actions); $dbField->setHasEmptyDefault(false); if ($isRunning) { foreach ($form->Fields() as $field) { $form->Fields()->replaceField($field->Name(), $field->performReadonlyTransformation()); } } return $form; }
public function testHasEmptyDefault() { $source = array(1 => 'one'); // Test getSource with empty $field = new DropdownField('Field', null, $source); $field->setHasEmptyDefault(true); $this->assertEquals($field->getSource(), array(1 => 'one')); // Test that an empty option comes through in the markup however $options = $this->findOptionElements($field->Field()); $this->assertEquals(2, count($options), 'Two options exist in the markup, one for the source, one for empty'); // the default value should be first $first = array_shift($options); $attrs = $first->attributes(); $this->assertNotEquals(1, $attrs['value'], 'First value is the not value (not the source value)'); // Test Field Without Empty $FieldWithoutEmpty = new DropdownField('Field', null, $source); $this->assertEquals($FieldWithoutEmpty->getSource(), array(1 => 'one')); $this->assertEquals(1, count($options), 'As hasEmptyDefault is not provided, then no default option.'); }
public function getCMSFields() { $fields = parent::getCMSFields(); $languageField = new DropdownField('Language', 'Language', array('af' => 'Afrikaans', 'sq' => 'Albanian', 'eu' => 'Basque', 'be' => 'Belarusian', 'bg' => 'Bulgarian', 'ca' => 'Catalan', 'zh-cn' => 'Chinese (Simplified)', 'zh-tw' => 'Chinese (Traditional)', 'hr' => 'Croatian', 'cs' => 'Czech', 'da' => 'Danish', 'nl' => 'Dutch', 'nl-be' => 'Dutch (Belgium)', 'nl-nl' => 'Dutch (Netherlands)', 'en' => 'English', 'en-au' => 'English (Australia)', 'en-bz' => 'English (Belize)', 'en-ca' => 'English (Canada)', 'en-ie' => 'English (Ireland)', 'en-jm' => 'English (Jamaica)', 'en-nz' => 'English (New Zealand)', 'en-ph' => 'English (Phillipines)', 'en-za' => 'English (South Africa)', 'en-tt' => 'English (Trinidad)', 'en-gb' => 'English (United Kingdom)', 'en-us' => 'English (United States)', 'en-zw' => 'English (Zimbabwe)', 'et' => 'Estonian', 'fo' => 'Faeroese', 'fi' => 'Finnish', 'fr' => 'French', 'fr-be' => 'French (Belgium)', 'fr-ca' => 'French (Canada)', 'fr-fr' => 'French (France)', 'fr-lu' => 'French (Luxembourg)', 'fr-mc' => 'French (Monaco)', 'fr-ch' => 'French (Switzerland)', 'gl' => 'Galician', 'gd' => 'Gaelic', 'de' => 'German', 'de-at' => 'German (Austria)', 'de-de' => 'German (Germany)', 'de-li' => 'German (Liechtenstein)', 'de-lu' => 'German (Luxembourg)', 'de-ch' => 'German (Switzerland)', 'el' => 'Greek', 'haw' => 'Hawaiian', 'hu' => 'Hungarian', 'is' => 'Icelandic', 'in' => 'Indonesian', 'ga' => 'Irish', 'it' => 'Italian', 'it-it' => 'Italian (Italy)', 'it-ch' => 'Italian (Switzerland)', 'ja' => 'Japanese', 'ko' => 'Korean', 'mk' => 'Macedonian', 'no' => 'Norwegian', 'pl' => 'Polish', 'pt' => 'Portuguese', 'pt-br' => 'Portuguese (Brazil)', 'pt-pt' => 'Portuguese (Portugal)', 'ro' => 'Romanian', 'ro-mo' => 'Romanian (Moldova)', 'ro-ro' => 'Romanian (Romania)', 'ru' => 'Russian', 'ru-mo' => 'Russian (Moldova)', 'ru-ru' => 'Russian (Russia)', 'sr' => 'Serbian', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'es' => 'Spanish', 'es-ar' => 'Spanish (Argentina)', 'es-bo' => 'Spanish (Bolivia)', 'es-cl' => 'Spanish (Chile)', 'es-co' => 'Spanish (Colombia)', 'es-cr' => 'Spanish (Costa Rica)', 'es-do' => 'Spanish (Dominican Republic)', 'es-ec' => 'Spanish (Ecuador)', 'es-sv' => 'Spanish (El Salvador)', 'es-gt' => 'Spanish (Guatemala)', 'es-hn' => 'Spanish (Honduras)', 'es-mx' => 'Spanish (Mexico)', 'es-ni' => 'Spanish (Nicaragua)', 'es-pa' => 'Spanish (Panama)', 'es-py' => 'Spanish (Paraguay)', 'es-pe' => 'Spanish (Peru)', 'es-pr' => 'Spanish (Puerto Rico)', 'es-es' => 'Spanish (Spain)', 'es-uy' => 'Spanish (Uruguay)', 'es-ve' => 'Spanish (Venezuela)', 'sv' => 'Swedish', 'sv-fi' => 'Swedish (Finland)', 'sv-se' => 'Swedish (Sweden)', 'tr' => 'Turkish', 'uk' => 'Ukranian')); $languageField->setHasEmptyDefault(true)->setEmptyString('Select Language'); $podcastImage = new UploadField('PodcastImage', 'Podcast Image'); $podcastImage->setFolderName('podcast/podcast-artwork')->setDescription("iTunes recommends a size of at least 1400x1400")->getValidator()->setAllowedExtensions(array('jpg', 'png')); $completeField = new CheckboxField('Complete'); $completeField->setDescription('This podcast is complete. No more episodes will be added to the podcast.'); $blockField = new CheckboxField('Block'); $blockField->setDescription('Prevent the <strong>entire</strong> podcast from appearing in the iTunes podcast directory.'); $explicitField = new DropdownField('Explicit', 'Explicit', $this->dbObject('Explicit')->enumValues()); $explicitField->setDescription("Displays an 'Explicit', 'Clean' or no parental advisory graphic next to your podcast artwork in iTunes."); $fields->addFieldsToTab('Root.Podcast', array(new TextField('PodcastTitle', 'Podcast Title'), new TextField('Subtitle'), $languageField, new TextField('Author'), new TextAreaField('Summary'), new TextField('OwnerName', 'Owner Name'), new EmailField('OwnerEmail', 'Owner Email'), new TextField('Copyright'), $completeField, $blockField, $explicitField, new TextAreaField('Keywords'), $podcastImage)); $config = GridFieldConfig_RelationEditor::create(); $episodesTable = new GridField('PodcastEpisodes', 'Podcast Episodes', $this->PodcastEpisodes()->sort('EpisodeDate', 'DESC'), $config); $fields->addFieldToTab('Root.Episodes', $episodesTable); return $fields; }
public function getCMSFields() { $fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true)); $fields->insertAfter(new ReadonlyField('ClassNameTranslated', _t('BaseElement.TYPE', 'Type'), $this->i18n_singular_name()), 'Title'); $fields->removeByName('ListID'); $fields->removeByName('ParentID'); $fields->removeByName('Sort'); $fields->removeByName('ExtraClass'); if (!$this->config()->enable_title_in_template) { $fields->removeByName('HideTitle'); $title = $fields->fieldByName('Root.Main.Title'); if ($title) { $title->setRightTitle('For reference only. Does not appear in the template.'); } } $fields->addFieldToTab('Root.Settings', new TextField('ExtraClass', 'Extra CSS Classes to add')); if (!is_a($this, 'ElementList')) { $lists = ElementList::get()->filter('ParentID', $this->ParentID); if ($lists->exists()) { $fields->addFieldToTab('Root.Settings', $move = new DropdownField('MoveToListID', 'Move this to another list', $lists->map('ID', 'CMSTitle'), '')); $move->setEmptyString('Select a list..'); $move->setHasEmptyDefault(true); } } if ($virtual = $fields->dataFieldByName('VirtualClones')) { if ($this->Parent() && $this->Parent()->exists() && $this->Parent()->getOwnerPage() && $this->Parent()->getOwnerPage()->exists()) { $tab = $fields->findOrMakeTab('Root.VirtualClones'); $tab->setTitle(_t('BaseElement.VIRTUALTABTITLE', 'Linked To')); $ownerPage = $this->Parent()->getOwnerPage(); $tab->push(new LiteralField('DisplaysOnPage', sprintf("<p>The original content block appears on <a href='%s'>%s</a></p>", $ownerPage->hasMethod('CMSEditLink') && $ownerPage->canEdit() ? $ownerPage->CMSEditLink() : $ownerPage->Link(), $ownerPage->MenuTitle))); $virtual->setConfig(new GridFieldConfig_Base()); $virtual->setTitle(_t('BaseElement.OTHERPAGES', 'Other pages'))->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter')->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldDetailForm')->addComponent(new ElementalGridFieldDeleteAction()); $virtual->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('getPage.Title' => 'Title', 'getPage.Link' => 'Link')); } } $this->extend('updateCMSFields', $fields); if ($this->IsInDB()) { if ($this->isEndofLine('BaseElement') && $this->hasExtension('VersionViewerDataObject')) { $fields = $this->addVersionViewer($fields, $this); } } return $fields; }
/** * @todo This should be generated by JavaScript, but we don't have the date libraries' */ function Field($properties = array()) { $this->addExtraClass('timedropdownfield'); $html = parent::Field($properties); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript('timedropdownfield/javascript/TimeDropdownField.js'); Requirements::css('timedropdownfield/css/TimeDropdownField.css'); $iteratedTime = new Zend_Date('00:00:00', 'h:mm:ss'); $options = array(); $count = 24 * (60 / $this->config['interval']); for ($i = 0; $i < $count; $i++) { $key = $iteratedTime->toString($this->getConfig('datavalueformat')); $options[$key] = $iteratedTime->toString($this->getConfig('timeformat')); $iteratedTime->add($this->config['interval'], Zend_Date::MINUTE); } $dropdownField = new DropdownField('dropdown_' . $this->getName(), false, $options, $this->Value()); $dropdownField->addExtraClass('presets'); $dropdownField->setHasEmptyDefault(true); $dropdownField->setForm($this->getForm()); $html .= $dropdownField->Field(); $html .= '<a href="#" class="presets-trigger"></a>'; return $html; }
/** * @return */ public function getCMSFields() { Requirements::javascript('memberprofiles/javascript/MemberProfileFieldCMS.js'); $fields = parent::getCMSFields(); $memberFields = $this->getMemberFields(); $memberField = $memberFields->dataFieldByName($this->MemberField); $fields->removeByName('MemberField'); $fields->removeByName('ProfilePageID'); $fields->fieldByName('Root.Main')->getChildren()->changeFieldOrder(array('CustomTitle', 'DefaultValue', 'Note', 'ProfileVisibility', 'RegistrationVisibility', 'MemberListVisible', 'PublicVisibility', 'PublicVisibilityDefault', 'CustomError', 'Unique', 'Required')); $fields->unshift(new ReadonlyField('MemberField', _t('MemberProfiles.MEMBERFIELD', 'Member Field'))); $fields->insertBefore(new HeaderField('VisibilityHeader', _t('MemberProfiles.VISIBILITY', 'Visibility')), 'ProfileVisibility'); $fields->insertBefore(new HeaderField('ValidationHeader', _t('MemberProfiles.VALIDATION', 'Validation')), 'CustomError'); if ($memberField instanceof DropdownField) { $fields->replaceField('DefaultValue', $default = new DropdownField('DefaultValue', _t('MemberProfiles.DEFAULTVALUE', 'Default Value'), $memberField->getSource())); $default->setHasEmptyDefault(true); } elseif ($memberField instanceof TextField) { $fields->replaceField('DefaultValue', new TextField('DefaultValue', _t('MemberProfiles.DEFAULTVALUE', 'Default Value'))); } else { $fields->removeByName('DefaultValue'); } $fields->dataFieldByName('PublicVisibility')->setSource(array('Display' => _t('MemberProfiles.ALWAYSDISPLAY', 'Always display'), 'MemberChoice' => _t('MemberProfiles.MEMBERCHOICE', 'Allow the member to choose'), 'Hidden' => _t('MemberProfiles.DONTDISPLAY', 'Do not display'))); $fields->dataFieldByName('PublicVisibilityDefault')->setTitle(_t('MemberProfiles.DEFAULTPUBLIC', 'Mark as public by default?')); $fields->dataFieldByName('MemberListVisible')->setTitle(_t('MemberProfiles.VISIBLEMEMLISTINGPAGE', 'Visible on the member listing page?')); if ($this->isNeverPublic()) { $fields->makeFieldReadonly('MemberListVisible'); $fields->makeFieldReadonly('PublicVisibility'); } if ($this->isAlwaysUnique()) { $fields->makeFieldReadonly('Unique'); } if ($this->isAlwaysRequired()) { $fields->makeFieldReadonly('Required'); } $this->extend('updateMemberProfileCMSFields', $fields); return $fields; }
/** * @return */ public function getCMSFields() { Requirements::javascript('memberprofiles/javascript/MemberProfileFieldCMS.js'); $fields = parent::getCMSFields(); $memberFields = $this->getMemberFields(); $memberField = $memberFields->dataFieldByName($this->MemberField); $fields->removeByName('MemberField'); $fields->removeByName('ProfilePageID'); $fields->fieldByName('Root.Main')->getChildren()->changeFieldOrder(array('CustomTitle', 'DefaultValue', 'Note', 'Visibility', 'Editable', 'Required')); $fields->unshift(new ReadonlyField('MemberField', _t('MemberProfiles.MEMBERFIELD', 'Member Field'))); $fields->insertBefore(new HeaderField('ValidationHeader', _t('MemberProfiles.VALIDATION', 'Validation')), 'CustomError'); if ($memberField instanceof DropdownField) { $fields->replaceField('DefaultValue', $default = new DropdownField('DefaultValue', _t('MemberProfiles.DEFAULTVALUE', 'Default Value'), $memberField->getSource())); $default->setHasEmptyDefault(true); } elseif ($memberField instanceof TextField) { $fields->replaceField('DefaultValue', new TextField('DefaultValue', _t('MemberProfiles.DEFAULTVALUE', 'Default Value'))); } else { $fields->removeByName('DefaultValue'); } $fields->dataFieldByName('Visibility')->setSource(array('Display' => _t('MemberProfiles.ALWAYSDISPLAY', 'Always display'), 'Hidden' => _t('MemberProfiles.DONTDISPLAY', 'Do not display'))); $fields->dataFieldByName('Editable')->setTitle(_t('MemberProfiles.DEFAULTPUBLIC', 'Can this field be edited?')); $this->extend('updateMemberProfileCMSFields', $fields); return $fields; }
/** * Presets the given dropdown field with the default tax rate * * @param DropdownField $dropdownField Dropdown field to manipulate * @param DataObject $object Tax rate related object * @param string $relationName Tax rate relation name * * @return SilvercartTax * * @author Sebastian Diel <*****@*****.**> * @since 26.10.2012 */ public static function presetDropdownWithDefault($dropdownField, $object, $relationName = 'SilvercartTax') { $relationIDName = $relationName . 'ID'; $dropdownField->setEmptyString(''); $dropdownField->setHasEmptyDefault(false); if ($object->{$relationIDName} == 0) { $defaultTaxRate = self::getDefault(); if ($defaultTaxRate) { $dropdownField->setValue($defaultTaxRate->ID); } } }
public function Tickets() { $result = new ArrayList(); $tickets = $this->datetime->Tickets('', '"RegistrableDateTime_Tickets"."Sort"'); foreach ($tickets as $ticket) { $available = $ticket->getAvailableForDateTime($this->datetime, $this->excludedRegistrationId); $endTime = $ticket->getSaleEndForDateTime($this->datetime); if ($avail = $available['available']) { $name = "{$this->name}[{$ticket->ID}]"; $min = $ticket->MinTickets; $max = $ticket->MaxTickets; $val = array_key_exists($ticket->ID, $this->value) ? $this->value[$ticket->ID] : null; if (!$val && !$this->showUnselectedTickets) { continue; } if ($this->readonly) { $field = $val ? $val : '0'; } elseif ($max) { $field = new DropdownField($name, '', ArrayLib::valuekey(range($min, min($available, $max))), $val, null); $field->setHasEmptyDefault(true); } else { $field = new NumericField($name, '', $val); } $result->push(new ArrayData(array('Title' => $ticket->Title, 'Description' => $ticket->Description, 'Available' => $avail === true ? 'Unlimited' : $avail, 'Price' => $ticket->PriceSummary(), 'End' => DBField::create_field('SS_Datetime', $endTime), 'Quantity' => $field))); } elseif ($this->showUnavailableTickets) { $availableAt = null; if (array_key_exists('available_at', $available)) { $availableAt = DBField::create_field('SS_Datetime', $available['available_at']); } $result->push(new ArrayData(array('Title' => $ticket->Title, 'Description' => $ticket->Description, 'Available' => false, 'Reason' => $available['reason'], 'AvailableAt' => $availableAt))); } } return $result; }
/** * 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 getSettingsFields() { $badges = array('auto' => 'Auto', 'inc' => 'Increment'); foreach (range(1, 5) as $val) { $badges[$val] = $val; } $applications = array_keys(self::$applications); if ($applications) { $applications = ArrayLib::valuekey($applications); } $fields = new FieldList($app = new DropdownField($this->getSettingFieldName('App'), _t('Push.UA_APP', 'Urban Airship Application'), $applications, $this->getSetting('App')), new CheckboxSetField($this->getSettingFieldName('Devices'), _t('Push.DEVICES', 'Devices'), array(self::ANDROID => 'Android', self::BLACKBERRY => 'Blackberry', self::IOS => 'iOS', self::MPNS => 'Windows Phone', self::WNS => 'Windows 8'), $this->getSetting('Devices')), new LiteralField('', sprintf('<p>%s</p>', _t('Push.UARECIPIENTSUPPORT', 'The Urban Airship provider does ' . 'not support selecting recipients - the push notification ' . 'will be sent to all devices using the broadcast API.'))), new HeaderField('IosOptionsHeader', _t('Push.IOSOPTIONS', 'iOS Options')), new DropdownField($this->getSettingFieldName('Sound'), _t('Push.UA_SOUND', 'Trigger sound when alert is received?'), array('No', 'Yes'), $this->getSetting('Sound')), new DropdownField($this->getSettingFieldName('Badge'), _t('Push.UA_BADGE', 'Badge'), $badges, $this->getSetting('Badge'))); $app->setHasEmptyDefault(true); return $fields; }
/** * Filter for order admin area search. * * @see DataObject::scaffoldSearchFields() * @return FieldSet */ function scaffoldSearchFields() { $fieldSet = parent::scaffoldSearchFields(); $statusField = new DropdownField('Status', 'Status', array(1 => "published", 2 => "not published")); $statusField->setHasEmptyDefault(true); $fieldSet->push($statusField); if ($categories = DataObject::get('ProductCategory')) { $categories->sort('MenuTitle'); $categoryOptions = $categories->map("ID", "MenuTitle"); //$fieldSet->push(new CheckboxSetField('Category', 'Category', $categoryOptions)); $dropDown = new DropdownField('Category', 'Category', $categoryOptions); $dropDown->setHasEmptyDefault(true); $fieldSet->push($dropDown); } return $fieldSet; }
function parameterFields() { $fields = new FieldSet(new TextField('OrderID', 'Order No'), new DateField('Created', 'Created'), $ddf = new DropdownField('Status', 'Status', singleton('Order')->dbObject('Status')->enumValues())); $ddf->setHasEmptyDefault(true); return $fields; }
/** * Returns the fields to power the edit screen of files in the CMS. * You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension} * and implemeting updateCMSFields(FieldList $fields) on that extension. * * @return FieldList */ public function getCMSFields() { // Preview if ($this instanceof Image) { $formattedImage = $this->getFormattedImage('ScaleWidth', Config::inst()->get('Image', 'asset_preview_width')); $thumbnail = $formattedImage ? $formattedImage->URL : ''; $previewField = new LiteralField("ImageFull", "<img id='thumbnailImage' class='thumbnail-preview' src='{$thumbnail}?r=" . rand(1, 100000) . "' alt='{$this->Name}' />\n"); } else { $previewField = new LiteralField("ImageFull", $this->CMSThumbnail()); } // Upload $uploadField = UploadField::create('UploadField', 'Upload Field')->setPreviewMaxWidth(40)->setPreviewMaxHeight(30)->setAllowedMaxFileNumber(1); //$uploadField->setTemplate('FileEditUploadField'); if ($this->ParentID) { $parent = $this->Parent(); if ($parent) { //set the parent that the Upload field should use for uploads $uploadField->setFolderName($parent->getFilename()); $uploadField->setRecord($parent); } } //create the file attributes in a FieldGroup $filePreview = CompositeField::create(CompositeField::create($previewField)->setName("FilePreviewImage")->addExtraClass('cms-file-info-preview'), CompositeField::create(CompositeField::create(new ReadonlyField("FileType", _t('AssetTableField.TYPE', 'File type') . ':'), new ReadonlyField("Size", _t('AssetTableField.SIZE', 'File size') . ':', $this->getSize()), $urlField = new ReadonlyField('ClickableURL', _t('AssetTableField.URL', 'URL'), sprintf('<a href="%s" target="_blank">%s</a>', $this->Link(), $this->RelativeLink())), new DateField_Disabled("Created", _t('AssetTableField.CREATED', 'First uploaded') . ':'), new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT', 'Last changed') . ':')))->setName("FilePreviewData")->addExtraClass('cms-file-info-data'))->setName("FilePreview")->addExtraClass('cms-file-info'); $urlField->dontEscape = true; //get a tree listing with only folder, no files $folderTree = new TreeDropdownField("ParentID", _t('AssetTableField.FOLDER', 'Folder'), 'Folder'); $fields = new FieldList(new TabSet('Root', new Tab('Main', $filePreview, new TextField("Title", _t('AssetTableField.TITLE', 'Title')), new TextField("Name", _t('AssetTableField.FILENAME', 'Filename')), $ownerField = new DropdownField("OwnerID", _t('AssetTableField.OWNER', 'Owner'), Member::mapInCMSGroups()), $folderTree))); $ownerField->setHasEmptyDefault(true); // Folder has its own updateCMSFields hook if (!$this instanceof Folder) { $this->extend('updateCMSFields', $fields); } return $fields; }
public function getDefaultSearchContext() { $context = parent::getDefaultSearchContext(); $context->removeFieldByName('Region'); $regions = self::get_regions(); if($regions) { $regionMap = array_combine($regions,$regions); } else { $regionMap = null; } $regionField = new DropdownField( 'Region', 'Region', $regionMap ); $regionField->setHasEmptyDefault(true); $context->addField($regionField); return $context; }
public function getHTMLFragments($gridField) { $fields = new ArrayList(); $state = $gridField->State->UserFormsGridField; $selectedField = $state->filter; $selectedValue = $state->value; // show dropdown of all the fields available from the submitted form fields // that have been saved. Takes the titles from the currently live form. $columnField = new DropdownField('FieldNameFilter', ''); $columnField->setSource($this->columns); $columnField->setEmptyString(_t('UserFormsGridFieldFilterHeader.FILTERSUBMISSIONS', 'Filter Submissions..')); $columnField->setHasEmptyDefault(true); $columnField->setValue($selectedField); $valueField = new TextField('FieldValue', '', $selectedValue); $columnField->addExtraClass('ss-gridfield-sort'); $columnField->addExtraClass('no-change-track'); $valueField->addExtraClass('ss-gridfield-sort'); $valueField->addExtraClass('no-change-track'); $valueField->setAttribute('placeholder', _t('UserFormsGridFieldFilterHeader.WHEREVALUEIS', 'where value is..')); $fields->push(new FieldGroup(new CompositeField($columnField, $valueField))); $fields->push(new FieldGroup(new CompositeField($start = new DateField('StartFilter', 'From'), $end = new DateField('EndFilter', 'Till')))); foreach (array($start, $end) as $date) { $date->setConfig('showcalendar', true); $date->setConfig('dateformat', 'y-mm-dd'); $date->setConfig('datavalueformat', 'y-mm-dd'); $date->addExtraClass('no-change-track'); } $end->setValue($state->end); $start->setValue($state->start); $fields->push($actions = new FieldGroup(GridField_FormAction::create($gridField, 'filter', false, 'filter', null)->addExtraClass('ss-gridfield-button-filter')->setAttribute('title', _t('GridField.Filter', "Filter"))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $columnField), GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-close')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField))); $actions->addExtraClass('filter-buttons'); $actions->addExtraClass('no-change-track'); $forTemplate = new ArrayData(array('Fields' => $fields)); return array('header' => $forTemplate->renderWith('GridFieldFilterHeader_Row')); }