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


PHP FieldList::replaceField方法代码示例

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


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

示例1: updateCMSFields

 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     // Redo LDAP metadata fields as read-only and move to LDAP tab.
     $ldapMetadata = array();
     $fields->replaceField('IsImportedFromLDAP', $ldapMetadata[] = new ReadonlyField('IsImportedFromLDAP', _t('LDAPMemberExtension.ISIMPORTEDFROMLDAP', 'Is user imported from LDAP/AD?')));
     $fields->replaceField('GUID', $ldapMetadata[] = new ReadonlyField('GUID'));
     $fields->replaceField('IsExpired', $ldapMetadata[] = new ReadonlyField('IsExpired', _t('LDAPMemberExtension.ISEXPIRED', 'Has user\'s LDAP/AD login expired?')));
     $fields->replaceField('LastSynced', $ldapMetadata[] = new ReadonlyField('LastSynced', _t('LDAPMemberExtension.LASTSYNCED', 'Last synced')));
     $fields->addFieldsToTab('Root.LDAP', $ldapMetadata);
     if ($this->owner->IsImportedFromLDAP) {
         // Transform the automatically mapped fields into read-only.
         $mappings = Config::inst()->get('Member', 'ldap_field_mappings');
         foreach ($mappings as $ldap => $ss) {
             $field = $fields->dataFieldByName($ss);
             if (!empty($field)) {
                 // This messes up the Member_Validator, preventing the record from saving :-(
                 // $field->setReadonly(true);
                 $field->setTitle($field->Title() . _t('LDAPMemberExtension.IMPORTEDFIELD', ' (imported)'));
             }
         }
         // Display alert message at the top.
         $message = _t('LDAPMemberExtension.INFOIMPORTED', 'This user is automatically imported from LDAP. ' . 'Manual changes to imported fields will be removed upon sync.');
         $fields->addFieldToTab('Root.Main', new LiteralField('Info', sprintf('<p class="message warning">%s</p>', $message)), 'FirstName');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-activedirectory,代码行数:28,代码来源:LDAPMemberExtension.php

示例2: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $avatar = new UploadField('Avatar', 'Avatar');
     $avatar->setFolderName('member/avatar');
     $fields->replaceField('Avatar', $avatar);
     $fields->removeByName('SortOrder');
 }
开发者ID:helpfulrobot,项目名称:phpboyscout-silverstripe-scouts,代码行数:7,代码来源:ScoutGroupLeaderExtension.php

示例3: getCMSFields

 public function getCMSFields($params = null)
 {
     //fields that shouldn't be changed once coupon is used
     $fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints")))));
     if (!$this->isInDB()) {
         $fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints");
     }
     if ($count = $this->getUseCount()) {
         $fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton"))));
     }
     if ($params && isset($params['forcetype'])) {
         $valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield;
         $fields->insertAfter($valuefield, "Type");
         $fields->makeFieldReadonly("Type");
     } else {
         if ($this->Type && (double) $this->{$this->Type}) {
             $valuefield = $this->Type == "Percent" ? $percentfield : $amountfield;
             $fields->makeFieldReadonly("Type");
             $fields->insertAfter($valuefield, "ActionTitle");
             $fields->replaceField($this->Type, $valuefield->performReadonlyTransformation());
             if ($this->Type == "Percent") {
                 $fields->insertAfter($maxamountfield, "Percent");
             }
         }
     }
     $this->extend("updateCMSFields", $fields, $params);
     return $fields;
 }
开发者ID:burnbright,项目名称:silverstripe-shop-discount,代码行数:28,代码来源:Discount.php

示例4: getCMSFields

 /**
  * Get the CMS view of the instance. This is used to display the log of
  * this workflow, and options to reassign if the workflow hasn't been
  * finished yet
  *
  * @return \FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList();
     if (Permission::check('REASSIGN_ACTIVE_WORKFLOWS')) {
         if ($this->WorkflowStatus == 'Paused' || $this->WorkflowStatus == 'Active') {
             $cmsUsers = Member::mapInCMSGroups();
             $fields->push(new HiddenField('DirectUpdate', '', 1));
             $fields->push(new HeaderField('InstanceReassignHeader', _t('WorkflowInstance.REASSIGN_HEADER', 'Reassign workflow')));
             $fields->push(new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Users'), $cmsUsers));
             $fields->push(new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Groups'), 'Group'));
         }
     }
     if ($this->canEdit()) {
         $action = $this->CurrentAction();
         if ($action->exists()) {
             $actionFields = $this->getWorkflowFields();
             $fields->merge($actionFields);
             $transitions = $action->getValidTransitions();
             if ($transitions) {
                 $fields->replaceField('TransitionID', DropdownField::create("TransitionID", "Next action", $transitions->map()));
             }
         }
     }
     $items = WorkflowActionInstance::get()->filter(array('Finished' => 1, 'WorkflowID' => $this->ID));
     $grid = new GridField('Actions', _t('WorkflowInstance.ActionLogTitle', 'Log'), $items);
     $fields->push($grid);
     return $fields;
 }
开发者ID:Neumes,项目名称:advancedworkflow,代码行数:35,代码来源:WorkflowInstance.php

示例5: updateCMSFields

 /**
  * Setup the CMS Fields
  *
  * @param FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (!$this->supportsElemental()) {
         return false;
     }
     // add an empty holder for content as some module explicitly use insert
     // after content.
     $fields->replaceField('Content', new LiteralField('Content', ''));
     $adder = new ElementalGridFieldAddNewMultiClass();
     $list = $this->getAvailableTypes();
     $adder->setClasses($list);
     $area = $this->owner->ElementArea();
     if (!$area->exists() || !$area->isInDB()) {
         $area->write();
         $this->owner->ElementAreaID = $area->ID;
         $this->owner->write();
     }
     $gridField = GridField::create('ElementArea', Config::inst()->get("ElementPageExtension", 'elements_title'), $this->owner->ElementArea()->Elements(), GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldAddExistingAutocompleter')->addComponent(new ElementalGridFieldAddExistingAutocompleter())->addComponent(new ElementalGridFieldDeleteAction())->addComponent($adder)->addComponent(new GridFieldSortableRows('Sort')));
     $config = $gridField->getConfig();
     $paginator = $config->getComponentByType('GridFieldPaginator');
     $paginator->setItemsPerPage(100);
     $config->removeComponentsByType('GridFieldDetailForm');
     $config->addComponent(new VersionedDataObjectDetailsForm());
     $fields->addFieldToTab('Root.Main', $gridField);
     return $fields;
 }
开发者ID:nyeholt,项目名称:silverstripe-elemental,代码行数:31,代码来源:ElementPageExtension.php

示例6: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // Changed Type to an optionset because drop down does not work sometimes in a dialog :-(
     // Also move sitetree to first item, I like that better.
     $types = $this->owner->config()->get('types');
     $i18nTypes = array();
     // Move SiteTree to first
     $i18nTypes['SiteTree'] = _t('Linkable.TYPE' . strtoupper('SiteTree'), $types['SiteTree']);
     foreach ($types as $key => $label) {
         $i18nTypes[$key] = _t('Linkable.TYPE' . strtoupper($key), $label);
     }
     $fields->replaceField('Type', OptionsetField::create('Type', _t('Linkable.LINKTYPE', 'Link Type'), $i18nTypes), 'OpenInNewWindow');
     // Chris Bolt, replaced file choose with an upload field
     $fields->replaceField('FileID', UploadField::create('File', _t('Linkable.FILE', 'File')), 'OpenInNewWindow');
     // Chris Bolt, added functionality for adding custom attributes
     $fields->addFieldToTab('Root.Main', TextField::create('ExtraAttributes', 'Extra Attributes')->setDescription('e.g. onClick="_gaq.push([\'_trackEvent\', \'whitepaper\', \'download\', pdfName, pdfValue, true]);"'));
 }
开发者ID:christopherbolt,项目名称:silverstripe-bolttools,代码行数:17,代码来源:BoltLink.php

示例7: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     Requirements::javascript(TINYMCE4_DIR . "/javascript/HtmlEditorField.js");
     Requirements::css(TINYMCE4_DIR . "/css/HtmlEditorField.css");
     if (Member::currentUser()) {
         CustomHtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     }
     $fields->replaceField("Content", CustomHtmlEditorField::create("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", 'HTML editor title'))->addExtraClass('stacked'));
 }
开发者ID:helpfulrobot,项目名称:mediaweb-silverstripe-tinymce4,代码行数:9,代码来源:SiteTreeTinyExtension.php

示例8: 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

示例9: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // remove if already scaffolded so we can add as editable grid field
     $fields->removeByName(self::RelationshipName);
     if ($this->showOnCMSForm()) {
         // hide the content field if we have sections.
         $fields->replaceField('Content', new HiddenField('Content'));
         $gridField = $this->makeEditableGridField(self::RelationshipName, $this->getFieldLabel(), self::RelatedModelClass, $this->ArtisanHasSections());
         $fields->addFieldToTab(self::get_config_setting('tab_name'), $gridField);
     }
 }
开发者ID:CrackerjackDigital,项目名称:artisan,代码行数:11,代码来源:ArtisanHasSections.php

示例10: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     if (Config::inst()->get('MarkdownExtension', 'replace_html_fields')) {
         foreach ($fields->dataFields() as $field) {
             if ($field instanceof HtmlEditorField) {
                 $attributes = $field->getAttributes();
                 $fields->replaceField($field->getName(), MarkdownEditorField::create($field->getName(), $field->Title())->setRows($attributes['rows']));
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-markdown,代码行数:11,代码来源:MarkdownExtension.php

示例11: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->UserSubmissionHolder()) {
         $fields->removeByName($this->owner->config()->remove_fields);
         $whitelist_fields = $this->owner->config()->whitelist_fields;
         foreach ($fields->dataFields() as $field) {
             if (!in_array($field->getName(), $whitelist_fields)) {
                 $fields->replaceField($field->getName(), $field->performReadonlyTransformation());
             }
         }
     }
 }
开发者ID:silbinarywolf,项目名称:usersubmissionpages,代码行数:12,代码来源:SubmittedFormFieldListingExtension.php

示例12: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // if there are Models set in the Product Category then use a dropdown to select
     if ($this->owner->Parent && $this->owner->Parent->ProductModels()->count()) {
         $fields->replaceField('Model', DropdownField::create('Model', _t("Product.MODELREQUIRED", "Model (required)"), ArrayLib::valuekey($this->owner->Parent->ProductModels()->column('Title')))->setEmptyString(_t("Product.MODELSELECT", "Select..."))->setAttribute('Required', true));
     } else {
         // Update Model for extended length
         // see config.yml for updated db settings
         $model = $fields->dataFieldByName('Model');
         $model->setMaxLength(100);
     }
 }
开发者ID:antonythorpe,项目名称:silvershop-productmodel,代码行数:12,代码来源:ProductModelExtension.php

示例13: updateCMSFields

 /**
  * Setup the CMS Fields
  *
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     // redirector pages should not have elements
     if (is_a($this->owner, 'RedirectorPage')) {
         return;
     } else {
         if ($ignored = Config::inst()->get('ElementPageExtension', 'ignored_classes')) {
             foreach ($ignored as $check) {
                 if (is_a($this->owner, $check)) {
                     return;
                 }
             }
         }
     }
     // add an empty holder for content as some module explicitly use insert
     // after content.
     $fields->replaceField('Content', new LiteralField('Content', ''));
     $adder = new ElementalGridFieldAddNewMultiClass();
     if (is_array($this->owner->config()->get('allowed_elements'))) {
         $list = $this->owner->config()->get('allowed_elements');
     } else {
         $classes = ClassInfo::subclassesFor('BaseElement');
         $list = array();
         unset($classes['BaseElement']);
         foreach ($classes as $class) {
             $inst = singleton($class);
             if ($inst->canCreate()) {
                 $list[$class] = singleton($class)->i18n_singular_name();
             }
         }
     }
     if (method_exists($this->owner, 'sortElementalOptions')) {
         $this->owner->sortElementalOptions($list);
     } else {
         asort($list);
     }
     $adder->setClasses($list);
     $area = $this->owner->ElementArea();
     if (!$area->exists() || !$area->isInDB()) {
         $area->write();
         $this->owner->ElementAreaID = $area->ID;
         $this->owner->write();
     }
     $gridField = GridField::create('ElementArea', Config::inst()->get("ElementPageExtension", 'elements_title'), $this->owner->ElementArea()->Elements(), GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldAddExistingAutocompleter')->removeComponentsByType('GridFieldDeleteAction')->addComponent(new GridFieldDeleteAction(false))->addComponent($adder)->addComponent(new GridFieldSortableRows('Sort')));
     $config = $gridField->getConfig();
     $paginator = $config->getComponentByType('GridFieldPaginator');
     $paginator->setItemsPerPage(100);
     $config->removeComponentsByType('GridFieldDetailForm');
     $config->addComponent(new VersionedDataObjectDetailsForm());
     $fields->addFieldToTab('Root.Main', $gridField, 'Metadata');
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:dnadesign-silverstripe-elemental,代码行数:57,代码来源:ElementPageExtension.php

示例14: updateFormFields

 /**
  * Updates the form fields for address'es to use a dropdown for the state and an additional field for the other state
  * @param {FieldList} $fields Fields to modify
  */
 public function updateFormFields(FieldList $fields)
 {
     $stateField = $fields->dataFieldByName('State');
     if ($stateField) {
         $newStateField = new GroupedDropdownField('State', $stateField->Title, array(_t('FedExStateProvinceExtension.UNITED_STATES', '_United States') => array('AL' => _t('FedExStateProvinceExtension.US_AL', '_Alabama'), 'LA' => _t('FedExStateProvinceExtension.US_LA', '_Louisiana'), 'OK' => _t('FedExStateProvinceExtension.US_OK', '_Oklahoma'), 'AK' => _t('FedExStateProvinceExtension.US_AK', '_Alaska'), 'ME' => _t('FedExStateProvinceExtension.US_ME', '_Maine'), 'OR' => _t('FedExStateProvinceExtension.US_OR', '_Oregon'), 'AZ' => _t('FedExStateProvinceExtension.US_AZ', '_Arizona'), 'MD' => _t('FedExStateProvinceExtension.US_MD', '_Maryland'), 'PA' => _t('FedExStateProvinceExtension.US_PA', '_Pennsylvania'), 'AR' => _t('FedExStateProvinceExtension.US_AR', '_Arkansas'), 'MA' => _t('FedExStateProvinceExtension.US_MA', '_Massachusetts'), 'RI' => _t('FedExStateProvinceExtension.US_RI', '_Rhode Island'), 'CA' => _t('FedExStateProvinceExtension.US_CA', '_California'), 'MI' => _t('FedExStateProvinceExtension.US_MI', '_Michigan'), 'SC' => _t('FedExStateProvinceExtension.US_SC', '_South Carolina'), 'CO' => _t('FedExStateProvinceExtension.US_CO', '_Colorado'), 'MN' => _t('FedExStateProvinceExtension.US_MN', '_Minnesota'), 'SD' => _t('FedExStateProvinceExtension.US_SD', '_South Dakota'), 'CT' => _t('FedExStateProvinceExtension.US_CT', '_Connecticut'), 'MS' => _t('FedExStateProvinceExtension.US_MS', '_Mississippi'), 'TN' => _t('FedExStateProvinceExtension.US_TN', '_Tennessee'), 'DE' => _t('FedExStateProvinceExtension.US_DE', '_Delaware'), 'MO' => _t('FedExStateProvinceExtension.US_MO', '_Missouri'), 'TX' => _t('FedExStateProvinceExtension.US_TX', '_Texas'), 'DC' => _t('FedExStateProvinceExtension.US_DC', '_District of Columbia'), 'MT' => _t('FedExStateProvinceExtension.US_MT', '_Montana'), 'UT' => _t('FedExStateProvinceExtension.US_UT', '_Utah'), 'FL' => _t('FedExStateProvinceExtension.US_FL', '_Florida'), 'NE' => _t('FedExStateProvinceExtension.US_NE', '_Nebraska'), 'VT' => _t('FedExStateProvinceExtension.US_VT', '_Vermont'), 'GA' => _t('FedExStateProvinceExtension.US_GA', '_Georgia'), 'NV' => _t('FedExStateProvinceExtension.US_NV', '_Nevada'), 'VA' => _t('FedExStateProvinceExtension.US_VA', '_Virginia'), 'HI' => _t('FedExStateProvinceExtension.US_HI', '_Hawaii'), 'NH' => _t('FedExStateProvinceExtension.US_NH', '_New Hampshire'), 'WA' => _t('FedExStateProvinceExtension.US_WA', '_Washington State'), 'ID' => _t('FedExStateProvinceExtension.US_ID', '_Idaho'), 'NJ' => _t('FedExStateProvinceExtension.US_NJ', '_New Jersey'), 'WV' => _t('FedExStateProvinceExtension.US_WV', '_West Virginia'), 'IL' => _t('FedExStateProvinceExtension.US_IL', '_Illinois'), 'NM' => _t('FedExStateProvinceExtension.US_NM', '_New Mexico'), 'WI' => _t('FedExStateProvinceExtension.US_WI', '_Wisconsin'), 'IN' => _t('FedExStateProvinceExtension.US_IN', '_Indiana'), 'NY' => _t('FedExStateProvinceExtension.US_NY', '_New York'), 'WY' => _t('FedExStateProvinceExtension.US_WY', '_Wyoming'), 'IA' => _t('FedExStateProvinceExtension.US_IA', '_Iowa'), 'NC' => _t('FedExStateProvinceExtension.US_NC', '_North Carolina'), 'PR' => _t('FedExStateProvinceExtension.US_PR', '_Puerto Rico'), 'KS' => _t('FedExStateProvinceExtension.US_KS', '_Kansas'), 'ND' => _t('FedExStateProvinceExtension.US_ND', '_North Dakota'), 'KY' => _t('FedExStateProvinceExtension.US_KY', '_Kentucky'), 'OH' => _t('FedExStateProvinceExtension.US_OH', '_Ohio')), _t('FedExStateProvinceExtension.CANADA', '_Canada') => array('AB' => _t('FedExStateProvinceExtension.CA_AB', '_Alberta'), 'BC' => _t('FedExStateProvinceExtension.CA_BC', '_British Columbia'), 'MB' => _t('FedExStateProvinceExtension.CA_MB', '_Manitoba'), 'NB' => _t('FedExStateProvinceExtension.CA_NB', '_New Brunswick'), 'NL' => _t('FedExStateProvinceExtension.CA_NL', '_Newfoundland'), 'NT' => _t('FedExStateProvinceExtension.CA_NT', '_Northwest Territories and Labrador'), 'NS' => _t('FedExStateProvinceExtension.CA_NS', '_Nova Scotia'), 'NU' => _t('FedExStateProvinceExtension.CA_NU', '_Nunavut'), 'ON' => _t('FedExStateProvinceExtension.CA_ON', '_Ontario'), 'PE' => _t('FedExStateProvinceExtension.CA_PE', '_Prince Edward Island'), 'QC' => _t('FedExStateProvinceExtension.CA_QC', '_Quebec'), 'SK' => _t('FedExStateProvinceExtension.CA_SK', '_Saskatchewan'), 'YT' => _t('FedExStateProvinceExtension.CA_YT', '_Yukon')), '' => _t('FedExStateProvinceExtension.OTHER', '_Other')));
         $newStateField->setDescription = $stateField->getDescription();
         $newStateField->setForm($stateField->getForm());
         $fields->replaceField('State', $newStateField);
         $fields->insertAfter($otherState = new TextField('OtherState', _t('FedExStateProvinceExtension.OTHER_STATE', '_Other State'), null, 200), 'State');
         $otherState->setDescription(_t('FedExStateProvinceExtension.OTHER_DESC', '_If you chose other as your state please place it here'));
         $otherState->setForm($stateField->getForm());
     }
 }
开发者ID:webbuilders-group,项目名称:silverstripe-shop-fedex-shipping,代码行数:17,代码来源:FedExStateProvinceExtension.php

示例15: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->Parent()->config()->get('hide_categories')) {
         $fields->removeByName('Categories');
     } else {
         if ($this->owner->config()->get('use_addnewlistboxfield')) {
             // Remove this once tagfield us fixed
             $list = new AddNewListboxField('Categories', 'Categories', $this->owner->Parent()->Categories()->map("ID", "Title")->toArray());
             $list->setMultiple(true);
             $list->setModel('BlogCategory')->setDialogTitle('New Category')->setBeforeWriteCallback(array($this->owner, 'AddNewDropDownFieldCategorisationCallback'));
             $fields->replaceField('Categories', $list);
         }
     }
     if ($this->owner->Parent()->config()->get('hide_tags')) {
         $fields->removeByName('Tags');
     } else {
         if ($this->owner->config()->get('use_addnewlistboxfield')) {
             // Remove this once tagfield us fixed
             $list = new AddNewListboxField('Tags', 'Tags', $this->owner->Parent()->Tags()->map("ID", "Title")->toArray());
             $list->setMultiple(true);
             $list->setModel('BlogTag')->setDialogTitle('New Tag')->setBeforeWriteCallback(array($this->owner, 'AddNewDropDownFieldCategorisationCallback'));
             $fields->replaceField('Tags', $list);
         }
     }
     if ($this->owner->config()->get('hide_authors')) {
         $fields->removeByName("Authors");
         $fields->removeByName("AuthorNames");
     }
     if ($this->owner->config()->get('hide_summary')) {
         $fields->removeByName("CustomSummary");
     }
     if ($this->owner->config()->get('hide_image')) {
         $fields->removeByName("FeaturedImage");
     } else {
         // Add description about ContentImage
         $fields->dataFieldByName('FeaturedImage')->setDescription(_t('BlogPost.FEATURED_IMAGE_DESCRIPTION', 'If no image is supplied then the first image found in the article content will be used if one exists.'));
     }
 }
开发者ID:christopherbolt,项目名称:silverstripe-bolttools,代码行数:38,代码来源:BoltBlogPost.php


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