本文整理汇总了PHP中FieldList::renameField方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::renameField方法的具体用法?PHP FieldList::renameField怎么用?PHP FieldList::renameField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldList
的用法示例。
在下文中一共展示了FieldList::renameField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab("Root.Main", new UploadField('Image', 'Main Image'), 'Content');
$fields->removeByName("Author");
if ($this->owner->ClassName == "BlogEntry") {
$fields->removeByName("Date");
} else {
$fields->renameField("Date", "Published Date");
}
}
示例2: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
//change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
/** @var TextField $titleField */
$titleField = $fields->dataFieldByName('Title');
if ($titleField->Title() == 'Page name') {
$fields->renameField('Title', 'Primary Heading');
}
//Add secondary heading - H2
$fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
$traits = $this->traitsUsedRecursive($this->owner->ClassName);
if ($this->owner->config()->get('has_on_after_update_cms_fields')) {
$traits[] = 'HasOnAfterUpdateCMSFieldsExtensionPoint';
}
if (!in_array('HasOnAfterUpdateCMSFieldsExtensionPoint', $traits)) {
$this->afterUpdateCMSFields($fields);
}
}
示例3: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$gridFieldConfig = GridFieldConfig_RecordEditor::create();
$gridFieldConfig->addComponent(new GridFieldBulkUpload());
$gridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));
$bulkUpload = $gridFieldConfig->getComponentByType('GridFieldBulkUpload');
$bulkUpload->setUfSetup('setFolderName', "Managed/PhotoGalleries/" . $this->owner->ID . "-" . $this->owner->URLSegment);
$bulkUpload->setUfConfig('canAttachExisting', false);
$bulkUpload->setUfConfig('canPreviewFolder', false);
$gridFieldConfig->removeComponentsByType('GridFieldPaginator');
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$gridFieldConfig->addComponent(new GridFieldPaginator(100));
$gridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
$gridfield = new GridField("PhotoGalleryImages", "Image Gallery", $this->owner->PhotoGalleryImages()->sort("SortOrder"), $gridFieldConfig);
$fields->addFieldToTab('Root.ImageGallery', $gridfield);
$fields->addFieldToTab('Root.ImageGallery', new LiteralField('help', "\n\t\t\t<h2>To upload new images:</h2>\n\t\t\t<ol>\n\t\t\t<li>1. Click the <strong>From your computer</strong> button above.</li>\n\t\t\t<li>2. <strong>Locate and select</strong> the image(s) you wish to upload.</li>\n\t\t\t<li>3. Click on <strong>Open/Choose</strong> and the image(s) will begin to upload.</li>\n\t\t\t<li>4. Click <strong>Finish</strong>.</li> \n\t\t\t</ol>"));
$fields->renameField("Content", "Top Content");
return $fields;
}
示例4: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
//change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
/** @var TextField $titleField */
$titleField = $fields->dataFieldByName('Title');
if ($titleField->Title() == 'Page Name') {
$fields->renameField('Title', 'Primary Heading');
}
//Add secondary heading - H2
$fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
//Move meta fields to their own tab
/** @var ToggleCompositeField $metaDataChildren */
$metaDataChildren = $fields->fieldByName('Root.Main.Metadata');
$children = array_merge([$metaTitle = TextField::create('MetaTitle')], $metaDataChildren->getChildren()->toArray());
$fields->removeFieldFromTab('Root.Main', 'Metadata');
$fields->addFieldToTab('Root', Tab::create('Metadata'), 'Content');
//Add META Title tag to METADATA
$fields->addFieldsToTab('Root.Metadata', $children);
$metaTitle->setDescription('Displayed as the tab/window name; Also displayed in search engine result listings as the page title.<br />
Falls back to the Primary Heading field if not provided.');
}
示例5: testRenameField
public function testRenameField()
{
$fields = new FieldList();
$nameField = new TextField('Name', 'Before title');
$fields->push($nameField);
/* The title of the field object is the same as what we put in */
$this->assertSame('Before title', $nameField->Title());
/* The field gets renamed to a different title */
$fields->renameField('Name', 'After title');
/* The title of the field object is the title we renamed to, this
includes the original object we created ($nameField), and getting
the field back out of the set */
$this->assertSame('After title', $nameField->Title());
$this->assertSame('After title', $fields->dataFieldByName('Name')->Title());
}
示例6: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->renameField('SkipToMainContentAccessKey', _t('AccessKey.SKIP_TO_MAIN_CONTENT_ACCESS_KEY'));
$fields->addFieldToTab('Root.FacebookMetadata', new UploadField('FacebookLogo', _t('Facebook.METADATA_LOGO', 'Image that will show in facebook when linking to this site. The image should be a square of minimum size 200px')));
}