当前位置: 首页>>代码示例>>PHP>>正文


PHP DropdownField::setHasEmptyDefault方法代码示例

本文整理汇总了PHP中DropdownField::setHasEmptyDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP DropdownField::setHasEmptyDefault方法的具体用法?PHP DropdownField::setHasEmptyDefault怎么用?PHP DropdownField::setHasEmptyDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DropdownField的用法示例。


在下文中一共展示了DropdownField::setHasEmptyDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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);
     }
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:14,代码来源:SetLocationForm.php

示例2: getCMSFields

 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;
 }
开发者ID:helpfulrobot,项目名称:dnadesign-silverstripe-elemental,代码行数:31,代码来源:BaseElement.php

示例3: testHasEmptyDefault

 public function testHasEmptyDefault()
 {
     $source = array(1 => 'one');
     $field = new DropdownField('Field', null, $source);
     $field->setHasEmptyDefault(true);
     $this->assertEquals($field->getSource(), array('' => '', 1 => 'one'));
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:7,代码来源:DropdownFieldTest.php

示例4: AddForm

 /**
  * @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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-metadata,代码行数:31,代码来源:MetaDataFieldAddForm.php

示例5: updateCMSFields

 /**
  * 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');
     }
 }
开发者ID:helpfulrobot,项目名称:heyday-silverstripe-adaptivecontent,代码行数:14,代码来源:AdaptiveContentIdentifiersAsTemplates.php

示例6: getCMSFields

 /**
  * 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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-openlayers,代码行数:23,代码来源:OLMapPage.php

示例7: Form

 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;
 }
开发者ID:normann,项目名称:silverstripe-frameworktest,代码行数:17,代码来源:FrameworktestRegressSessionAdmin.php

示例8: testHasEmptyDefault

 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.');
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:19,代码来源:DropdownFieldTest.php

示例9: getCMSFields

 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;
 }
开发者ID:helpfulrobot,项目名称:lukereative-silverstripe-podcast,代码行数:19,代码来源:PodcastPage.php

示例10: getCMSFields

 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;
 }
开发者ID:dnadesign,项目名称:silverstripe-elemental,代码行数:43,代码来源:BaseElement.php

示例11: Field

 /**
  * @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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-timedropdownfield,代码行数:27,代码来源:TimeDropdownField.php

示例12: getCMSFields

 /**
  * @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;
 }
开发者ID:SilbinaryWolf,项目名称:silverstripe-memberprofiles,代码行数:39,代码来源:MemberProfileField.php

示例13: getCMSFields

 /**
  * @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;
 }
开发者ID:helpfulrobot,项目名称:zucchi-membermanagement,代码行数:27,代码来源:MembersAccountField.php

示例14: presetDropdownWithDefault

 /**
  * 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 <sdiel@pixeltricks.de>
  * @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);
         }
     }
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:24,代码来源:SilvercartTax.php

示例15: Tickets

 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;
 }
开发者ID:helpfulrobot,项目名称:ajshort-silverstripe-eventmanagement,代码行数:34,代码来源:EventRegistrationTicketsTableField.php


注:本文中的DropdownField::setHasEmptyDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。