本文整理汇总了PHP中GridFieldConfig_RecordEditor::getComponentByType方法的典型用法代码示例。如果您正苦于以下问题:PHP GridFieldConfig_RecordEditor::getComponentByType方法的具体用法?PHP GridFieldConfig_RecordEditor::getComponentByType怎么用?PHP GridFieldConfig_RecordEditor::getComponentByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridFieldConfig_RecordEditor
的用法示例。
在下文中一共展示了GridFieldConfig_RecordEditor::getComponentByType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
public function getCMSFields()
{
//scaffold cms fields without calling 'updateCMSFields'
$fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true));
if ($grid = $fields->fieldByName("Root.ProductSelections.ProductSelections")) {
//move field to main tab
$fields->removeByName("ProductSelections");
$fields->addFieldToTab("Root.Main", $grid);
$grid->setConfig($conf = new GridFieldConfig_RecordEditor());
$conf->removeComponentsByType("GridFieldDataColumns")->removeComponentsByType("GridFieldDataColumns")->removeComponentsByType("GridFieldFilterHeader")->removeComponentsByType("GridFieldPaginator")->removeComponentsByType("GridFieldPageCount")->addComponent(new GridFieldOrderableRows())->addComponent(new GridFieldEditableColumns());
$summaryfields = MenuProductSelection::config()->summary_fields;
unset($summaryfields['Group']);
//add editable group column to grid
$groups = $this->Groups();
if ($groups->exists()) {
$dropdown = DropdownField::create("GroupID", 'Grouping', $groups->map('ID', 'Title')->toArray())->setHasEmptyDefault(true);
$summaryfields['GroupID'] = array('title' => 'Group', 'callback' => function ($record, $column, $grid) use($dropdown) {
return $dropdown;
});
$conf->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form, $component) use($dropdown) {
$fields = $form->Fields();
if (!$fields->fieldByName("GroupID")) {
$fields->push($dropdown);
}
});
}
$conf->getComponentByType('GridFieldEditableColumns')->setDisplayFields($summaryfields);
//re-add edit/delete row actions so they are in the correct order
$conf->removeComponentsByType("GridFieldEditButton")->removeComponentsByType("GridFieldDeleteAction")->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent($importer = new GridFieldImporter('before'));
$loader = $importer->getLoader($grid);
$self = $this;
$loader->mappableFields = array('Product.InternalItemID' => 'SKU / Product Identifier', 'Group.Title' => 'Group');
$loader->transforms = array("Product.InternalItemID" => array("create" => false, "link" => true, "required" => true), "Group.Title" => array('list' => $this->Groups()));
$loader->duplicateChecks = array("Product.InternalItemID" => "Product.InternalItemID");
}
if ($grid = $fields->fieldByName("Root.Groups.Groups")) {
$conf = $grid->getConfig()->removeComponentsByType("GridFieldAddExistingAutocompleter")->removeComponentsByType('GridFieldDataColumns')->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType("GridFieldFilterHeader")->removeComponentsByType("GridFieldPaginator")->removeComponentsByType("GridFieldPageCount")->addComponent($newbutton = new GridFieldAddNewInlineButton())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldOrderableRows());
$newbutton->setTitle("Add Menu Grouping");
$conf->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array('Title' => function ($record, $column, $grid) {
return new TextField($column, 'Title');
}));
//re-add edit/delete row actions so they are in the correct order
$conf->removeComponentsByType("GridFieldEditButton")->removeComponentsByType("GridFieldDeleteAction")->addComponent(new GridFieldDeleteAction());
}
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例2: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->insertBefore(new Tab('About'), 'Settings');
$fields->insertBefore(new Tab('Host'), 'Settings');
// header
$fields->removeByName('Content');
$fields->addFieldToTab('Root.Main', $uploadField = new UploadField('HeaderPics', 'Header Pictures'));
$uploadField->setAllowedMaxFileNumber(10);
$uploadField->setFolderName('openstackdays');
// About
$fields->addFieldToTab('Root.About', $about_desc = new HtmlEditorField('AboutDescription', 'Intro Text', $this->AboutDescription));
$config = new GridFieldConfig_RecordEditor(10);
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('YoutubeID' => 'YoutubeID', 'Caption' => 'Caption', 'Active' => 'Active'));
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.About', new GridField('AboutVideos', 'Videos', $this->AboutVideos(), $config));
// Host
$fields->addFieldToTab('Root.Host', $host_intro = new HtmlEditorField('HostIntro', 'Intro Text', $this->HostIntro));
$fields->addFieldToTab('Root.Host', $host_faq = new HtmlEditorField('HostFAQs', 'FAQs', $this->HostFAQs));
$fields->addFieldToTab('Root.Host', $toolkit_text = new HtmlEditorField('ToolkitDesc', 'Toolkit Text', $this->ToolkitDesc));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Host', new GridField('OfficialGuidelines', 'Official Guidelines', $this->OfficialGuidelines(), $config));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Host', new GridField('PlanningTools', 'Planning Tools', $this->PlanningTools(), $config));
$fields->addFieldToTab('Root.Host', $artwork_intro = new HtmlEditorField('ArtworkIntro', 'Artwork intro text', $this->ArtworkIntro));
$artwork_intro->setRows(4);
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Host', new GridField('Artwork', 'Artwork', $this->Artwork(), $config));
$fields->addFieldToTab('Root.Host', $collateral_intro = new HtmlEditorField('CollateralIntro', 'Collateral intro text', $this->CollateralIntro));
$collateral_intro->setRows(4);
$config = new GridFieldConfig_RecordEditor(10);
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('YoutubeID' => 'YoutubeID', 'Caption' => 'Caption', 'Active' => 'Active'));
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Host', new GridField('Collaterals', 'Video / Presentations / Collateral', $this->Collaterals(), $config));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Host', new GridField('Media', 'PR / Media', $this->Media(), $config));
return $fields;
}
示例3: updateCMSFields
/**
* @param FieldList $fields
* @return FieldList|void
*/
public function updateCMSFields(FieldList $fields)
{
$oldFields = $fields->toArray();
foreach ($oldFields as $field) {
$fields->remove($field);
}
$fields->push(new LiteralField("Title", "<h2>OpenStack Release</h2>"));
$fields->push(new TextField("Name", "Name"));
$date = DateField::create('ReleaseDate')->setConfig('showcalendar', true);
$fields->push($date);
$date->setTitle('Release Date');
$fields->push(new TextField("ReleaseNumber", "Release Number"));
$fields->push(new TextField("ReleaseNotesUrl", "Release Notes Url"));
$fields->push(new DropdownField('Status', 'Status', $this->owner->dbObject('Status')->enumValues()));
//components
if ($this->owner->ID > 0) {
$components_config = new GridFieldConfig_RelationEditor(100);
$components = new GridField("OpenStackComponents", "Supported Release Components", $this->owner->OpenStackComponents(), $components_config);
$components_config->removeComponentsByType('GridFieldAddNewButton');
$fields->push($components);
//supported versions
//only if we have components set
if ($this->owner->OpenStackComponents()->filter('SupportsVersioning', true)->count() > 0) {
$supported_versions_config = new GridFieldConfig_RecordEditor(100);
$dataColumns = $supported_versions_config->getComponentByType('GridFieldDataColumns');
$dataColumns->setDisplayFields(array('OpenStackComponent.CodeName' => 'Component CodeName', 'OpenStackComponent.Name' => 'Component Name', 'ApiVersion.Version' => 'Api Version'));
//$supported_versions_config->removeComponentsByType('GridFieldEditButton');
$supported_versions = new GridField("SupportedApiVersions", "Supported Release Components", $this->owner->SupportedApiVersions(" ReleaseID = {$this->owner->getIdentifier()} AND OpenStackComponent.SupportsVersioning = 1 ")->innerJoin('OpenStackComponent', 'OpenStackComponent.ID = OpenStackReleaseSupportedApiVersion.OpenStackComponentID'), $supported_versions_config);
$fields->push($supported_versions);
}
$config = new GridFieldConfig_RecordEditor(100);
$config_types = new GridField("SampleConfigurationTypes", "Sample Configuration Types", $this->owner->SampleConfigurationTypes(), $config);
$config->addComponent(new GridFieldSortableRows('Order'));
$fields->push($config_types);
}
return $fields;
}