本文整理汇总了PHP中GridFieldConfig_RecordEditor类的典型用法代码示例。如果您正苦于以下问题:PHP GridFieldConfig_RecordEditor类的具体用法?PHP GridFieldConfig_RecordEditor怎么用?PHP GridFieldConfig_RecordEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GridFieldConfig_RecordEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
foreach (['primary', 'secondary'] as $lower) {
$upper = ucfirst($lower);
$config = $this->owner->config()->get("{$lower}_gallery");
if (is_null($config) || isset($config['enabled']) && $config['enabled'] === false) {
continue;
}
$config['title'] = isset($config['title']) ? $config['title'] : "{$upper} Gallery";
$config['folder'] = isset($config['folder']) ? $config['folder'] : "{$upper}-Gallery-Images";
$GridFieldConfig = new GridFieldConfig_RecordEditor();
$GridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
$GridFieldConfig->addComponent($bulkUploadConfig = new GridFieldBulkUpload());
$GridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$GridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));
$bulkUploadConfig->setUfSetup('setFolderName', "Images/{$config['folder']}");
$GridField = new GridField("{$upper}GalleryGridField", $config['title'], $this->owner->{"{$upper}GalleryImages"}(), $GridFieldConfig);
/** @var TabSet $rootTab */
//We need to repush Metadata to ensure it is the last tab
$rootTab = $fields->fieldByName('Root');
$rootTab->push($tab = Tab::create("{$upper}Gallery"));
if ($rootTab->fieldByName('Metadata')) {
$metaChildren = $rootTab->fieldByName('Metadata')->getChildren();
$rootTab->removeByName('Metadata');
$rootTab->push(Tab::create('Metadata')->setChildren($metaChildren));
}
$tab->setTitle($config['title']);
$fields->addFieldToTab("Root.{$upper}Gallery", $GridField);
}
}
示例2: 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 Component</h2>"));
$fields->push(new TextField("Name", "Name"));
$fields->push(new TextField("CodeName", "Code Name"));
$fields->push(new TextField("Description", "Description"));
$fields->push(new CheckboxField('SupportsVersioning', 'Supports Versioning?'));
$fields->push(new CheckboxField('SupportsExtensions', 'Supports Extensions?'));
$fields->push(new CheckboxField('IsCoreService', 'Is Core Service?'));
$fields->push(new DropdownField('IconClass', 'Font Awesome Icon CSS Class', $this->owner->dbObject('IconClass')->enumValues()));
$fields->push(new DropdownField('Use', 'OpenStack Usage', $this->owner->dbObject('Use')->enumValues()));
if ($this->owner->getSupportsVersioning()) {
$versions_config = new GridFieldConfig_RecordEditor();
$versions = new GridField("Versions", "Versions", $this->owner->Versions(), $versions_config);
$fields->push($versions);
}
$config = new GridFieldConfig_RecordEditor();
$config->addComponent(new GridFieldSortableRows('Order'));
$related_content = new GridField("RelatedContent", "RelatedContent", $this->owner->RelatedContent(), $config);
$fields->push($related_content);
return $fields;
}
示例3: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$badge = new UploadField('Badge', _t('ScoutGroup.BADGE', 'Badge'));
$badge->setFolderName('group/badge');
$badge->setRightTitle(_t('ScoutGroup.BADGE_HELP', 'The badge/logo/emblem of the Group'))->addExtraClass('help');
$fields->addFieldToTab('Root.Info', $badge);
$necker = new UploadField('Necker', _t('ScoutGroup.NECKER', 'Necker'));
$necker->setFolderName('group/necker');
$necker->setRightTitle(_t('ScoutGroup.NECKER_HELP', 'The neckerchief the Group'))->addExtraClass('help');
$fields->addFieldToTab('Root.Info', $necker);
$fields->addFieldToTab('Root.Info', new TextField('NeckerDescription', _t('ScoutGroup.NECKERDESCRIPTION', 'Neckerchief Description')));
$fields->addFieldToTab('Root.Social', new TextField('TwitterUser', _t('ScoutGroup.TWITTERUSER', 'Twitter User')));
$fields->addFieldToTab('Root.Social', new TextField('FacebookPage', _t('ScoutGroup.FACEBOOKPAGE', 'Facebook Page')));
$fields->addFieldToTab('Root.Social', new TextField('GooglePage', _t('ScoutGroup.GOOGLEPAGE', 'Google Page')));
$fields->addFieldToTab('Root.Contact', new TextField('Address1', _t('ScoutGroup.ADDRESS1', 'Address 1')));
$fields->addFieldToTab('Root.Contact', new TextField('Address2', _t('ScoutGroup.ADDRESS2', 'Address 2')));
$fields->addFieldToTab('Root.Contact', new TextField('Address3', _t('ScoutGroup.ADDRESS3', 'Address 3')));
$fields->addFieldToTab('Root.Contact', new TextField('Town', _t('ScoutGroup.TOWN', 'Town')));
$fields->addFieldToTab('Root.Contact', new TextField('Postcode', _t('ScoutGroup.POSTCODE', 'Post Code')));
$fields->addFieldToTab('Root.Contact', new TextField('Phone', _t('ScoutGroup.PHONE', 'Phone #')));
$fields->addFieldToTab('Root.Contact', new TextField('Email', _t('ScoutGroup.EMAIL', 'Email Address')));
$fields->addFieldToTab('Root.Contact', new TextField('CharityNumber', _t('ScoutGroup.CHARITYNUMBER', 'CharityNumber')));
$sectionGridConfig = new GridFieldConfig_RecordEditor();
$sectionGridConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$sectionGrid = new GridField('Sections', 'Sections', $this->Sections(), $sectionGridConfig);
$fields->addFieldToTab('Root.Sections', $sectionGrid);
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例4: 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 TextField("Title", "Title"));
$fields->push(new HtmlEditorField("Summary", "Summary"));
$fields->push(new HtmlEditorField("Description", "Description"));
$fields->push(new MemberAutoCompleteField("Curator", "Curator"));
$fields->push($ddl = new DropdownField('ReleaseID', 'Release', OpenStackRelease::get()->map("ID", "Name")));
$ddl->setEmptyString('-- Select a Release --');
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->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchList($this->getAllowedComponents());
$components_config->removeComponentsByType('GridFieldAddNewButton');
//$components_config->addComponent(new GridFieldSortableRows('OpenStackSampleConfig_OpenStackComponents.Order'));
$fields->push($components);
$fields->push($ddl = new DropdownField('TypeID', 'Type', OpenStackSampleConfigurationType::get()->filter('ReleaseID', $this->owner->ReleaseID)->map("ID", "Type")));
$ddl->setEmptyString('-- Select a Configuration Type --');
$related_notes_config = new GridFieldConfig_RecordEditor(100);
$related_notes = new GridField("RelatedNotes", "Related Notes", $this->owner->RelatedNotes(), $related_notes_config);
$related_notes_config->addComponent(new GridFieldSortableRows('Order'));
$fields->push($related_notes);
}
return $fields;
}
示例5: updateCMSFields
/**
* @param FieldList $fields
*/
public function updateCMSFields(FieldList $fields)
{
$items = $this->owner->FeaturedItems();
$gridCfg = new GridFieldConfig_RecordEditor(1000);
// we use RecordEditor instead of RelationEditor so it deletes instead of unlinks
if (class_exists('GridFieldOrderableRows') && !$items instanceof UnsavedRelationList) {
$gridCfg->addComponent(new GridFieldOrderableRows('Sort'));
}
$grid = new GridField('FeaturedItems', 'Featured Items', $items, $gridCfg);
$fields->addFieldToTab('Root.FeaturedItems', $grid);
}
示例6: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->insertBefore(new Tab('GetInvolved'), 'Settings');
$fields->insertBefore(new Tab('Events'), 'Settings');
$fields->insertBefore(new Tab('Collateral'), 'Settings');
$fields->insertBefore(new Tab('Software'), 'Settings');
$fields->insertBefore(new Tab('Graphics'), 'Settings');
$fields->insertBefore(new Tab('Promote'), 'Settings');
// header
$fields->removeByName('Content');
$fields->addFieldToTab('Root.Main', new TextField('HeaderTitle', 'Header Title'));
$fields->addFieldToTab('Root.Main', new HtmlEditorField('HeaderText', 'Header Text'));
// Get Involved
$fields->addFieldToTab('Root.GetInvolved', $involved_images = new UploadField('InvolvedImages', 'Involved Images'));
$involved_images->setFolderName('marketing');
$fields->addFieldToTab('Root.GetInvolved', new HtmlEditorField('InvolvedText', 'Involved Text', $this->InvolvedText));
// Events
$fields->addFieldToTab('Root.Events', new HtmlEditorField('EventsIntroText', 'Events Intro Text', $this->EventsIntroText));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Events', new GridField('SponsorEvents', 'SponsorEvents', $this->SponsorEvents(), $config));
// Collateral
$fields->addFieldToTab('Root.Collateral', new HtmlEditorField('CollateralIntroText', 'Collateral Intro Text', $this->CollateralIntroText));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Collateral', new GridField('Collaterals', 'Collaterals', $this->Collaterals(), $config));
// Software
$fields->addFieldToTab('Root.Software', new HtmlEditorField('SoftwareIntroText', 'Software Intro Text', $this->SoftwareIntroText));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Software', new GridField('Software', 'Software', $this->Software(), $config));
// Graphics
$fields->addFieldToTab('Root.Graphics', new HtmlEditorField('GraphicsIntroText', 'Graphics Intro Text', $this->GraphicsIntroText));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Graphics', new GridField('Stickers', 'Stickers', $this->Stickers(), $config));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Graphics', new GridField('TShirts', 'TShirts', $this->TShirts(), $config));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Graphics', new GridField('Banners', 'Banners', $this->Banners(), $config));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Graphics', new GridField('Videos', 'Videos', $this->Videos(), $config));
// Promote
$fields->addFieldToTab('Root.Promote', $about_desc = new HtmlEditorField('PromoteProductIntroText', 'Promote Intro Text', $this->PromoteProductIntroText));
$config = new GridFieldConfig_RecordEditor(3);
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$fields->addFieldToTab('Root.Promote', new GridField('PromoteEvents', 'PromoteEvents', $this->PromoteEvents(), $config));
return $fields;
}
示例7: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('Content');
$fields->addFieldsToTab('Root.Main', new TextField('IntroTitle', 'Intro Title'));
$fields->addFieldsToTab('Root.Main', new HtmlEditorField('IntroText', 'Intro Text'));
$fields->addFieldsToTab('Root.Main', new TextField('IntroTitle2', 'Intro Title 2'));
$fields->addFieldsToTab('Root.Main', new HtmlEditorField('IntroText2', 'Intro Text 2'));
$config = new GridFieldConfig_RecordEditor(100);
$sub_menu = new GridField("SubMenuPages", "SubMenu Pages", $this->SubMenuPages(), $config);
$config->addComponent(new GridFieldSortableRows('Order'));
$fields->push($sub_menu);
return $fields;
}
示例8: addCategoriesTab
private function addCategoriesTab($fields)
{
$config = GridFieldConfig_RecordEditor::create();
$config->addComponent(new GridFieldSortableRows('SortOrder'));
$categoriesField = new GridField('Categories', 'Categories', $this->Categories(), $config);
$fields->addFieldToTab('Root.Categories', $categoriesField);
}
示例9: getEditForm
public function getEditForm($id = null, $fields = null)
{
// TODO Duplicate record fetching (see parent implementation)
if (!$id) {
$id = $this->currentPageID();
}
$form = parent::getEditForm($id);
// TODO Duplicate record fetching (see parent implementation)
$record = $this->getRecord($id);
if ($record && !$record->canView()) {
return Security::permissionFailure($this);
}
$memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldButtonRow('after'))->addComponent(new GridFieldExportButton('buttons-after-left')))->addExtraClass("members_grid");
if ($record && method_exists($record, 'getValidator')) {
$validator = $record->getValidator();
} else {
$validator = Injector::inst()->get('Member')->getValidator();
}
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
$groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
$columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array('Breadcrumbs' => singleton('Group')->fieldLabel('Title')));
$columns->setFieldFormatting(array('Breadcrumbs' => function ($val, $item) {
return Convert::raw2xml($item->getBreadcrumbs(' > '));
}));
$fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the' . ' database')))), $groupsTab = new Tab('Groups', singleton('Group')->i18n_plural_name(), $groupList)), new HiddenField('ID', false, 0));
// Add import capabilities. Limit to admin since the import logic can affect assigned permissions
if (Permission::check('ADMIN')) {
$fields->addFieldsToTab('Root.Users', array(new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('memberimport')))));
$fields->addFieldsToTab('Root.Groups', array(new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('groupimport')))));
}
// Tab nav in CMS is rendered through separate template
$root->setTemplate('CMSTabSet');
// Add roles editing interface
if (Permission::check('APPLY_ROLES')) {
$rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
$rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
$rolesTab->push($rolesField);
}
$actionParam = $this->getRequest()->param('Action');
if ($actionParam == 'groups') {
$groupsTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'users') {
$usersTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'roles') {
$rolesTab->addExtraClass('ui-state-active');
}
$actions = new FieldList();
$form = Form::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// Tab nav in CMS is rendered through separate template
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
$this->extend('updateEditForm', $form);
return $form;
}
示例10: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab("Root.SuccessContent", array(TextField::create("Currency"), TextField::create("SuccessTitle"), HTMLEditorField::create("SuccessContent")));
$fields->addFieldToTab("Root.Invoices", GridField::create("Invoices", "Invoices", $this->Invoices(), GridFieldConfig_RecordEditor::create()));
return $fields;
}
示例11: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('IndustryName' => 'IndustryName', 'Active' => 'Active'));
$industries = new GridField('UserStoriesIndustry', 'User Stories Industry', UserStoriesIndustry::get(), $config);
$fields->addFieldsToTab('Root.Industries', $industries);
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('UserStory.Title' => 'UserStory', 'UserStoriesIndustry.IndustryName' => 'Industry'));
$Featured = new GridField('UserStoriesFeatured', 'User Stories Featured', UserStoriesFeatured::get(), $config);
$fields->addFieldsToTab('Root.FeaturedStories', $Featured);
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('LinkName' => 'LinkName', 'UserStory.Title' => 'UserStory'));
$links = new GridField('UserStoriesLink', 'User Stories Link', UserStoriesLink::get(), $config);
$fields->addFieldsToTab('Root.Links', $links);
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Topic' => 'Topic'));
$topics = new GridField('UserStoriesTopics', 'User Stories Topics', UserStoriesTopics::get(), $config);
$fields->addFieldsToTab('Root.Topics', $topics);
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('UserStoriesTopics.Topic' => 'Topic', 'LabelTitle' => 'Title'));
$TopicsFeatured = new GridField('UserStoriesTopicsFeatured', 'User Stories Topics Featured', UserStoriesTopicsFeatured::get(), $config);
$fields->addFieldsToTab('Root.FeaturedOnSlider', $TopicsFeatured);
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Type' => 'Type', 'Content' => 'Content'));
$slides = new GridField('UserStoriesSlides', 'User Stories Slides', UserStoriesSlides::get(), $config);
$fields->addFieldsToTab('Root.Slides', $slides);
return $fields;
}
示例12: getCMSFields
/**
* Setup the CMS Fields for the User Defined Form
*
* @return FieldSet
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
// define tabs
$fields->findOrMakeTab('Root.Form', _t('UserDefinedForm.FORM', 'Form'));
$fields->findOrMakeTab('Root.Options', _t('UserDefinedForm.OPTIONS', 'Options'));
$fields->findOrMakeTab('Root.EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'));
$fields->findOrMakeTab('Root.OnComplete', _t('UserDefinedForm.ONCOMPLETE', 'On Complete'));
$fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
// field editor
$fields->addFieldToTab("Root.Form", new FieldEditor("Fields", 'Fields', "", $this));
// view the submissions
$fields->addFieldToTab("Root.Submissions", new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', "Disable Saving Submissions to Server")));
$fields->addFieldToTab("Root.Submissions", new SubmittedFormReportField("Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this));
UserDefinedForm_EmailRecipient::$summary_fields = array('EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From'));
// who do we email on submission
$emailRecipients = new GridField("EmailRecipients", "EmailRecipients", $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10));
$fields->addFieldToTab("Root.EmailRecipients", $emailRecipients);
// text to show on complete
$onCompleteFieldSet = new FieldList($editor = new HtmlEditorField("OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'), _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage)));
$editor->setRows(3);
$fields->addFieldsToTab("Root.OnComplete", $onCompleteFieldSet);
$fields->addFieldsToTab("Root.Options", $this->getFormOptions());
return $fields;
}
示例13: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldsToTab("Root.Banners", GridField::create("Banners", null, $this->owner->Banners(), $config = GridFieldConfig_RecordEditor::create()));
if (class_exists("GridFieldOrderableRows")) {
$config->addComponent(new GridFieldOrderableRows());
}
}
示例14: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->insertBefore(TextareaField::create('Intro', 'Intro'), 'Content');
$fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Intro");
$fields->insertBefore($image = UploadField::create('SplashImage', 'Splash Image'), 'Content');
$image->setFolderName('Uploads/Splash-Images');
if ($this->ClassName === "Page" || $this->ClassName === "HomePage") {
$fields->insertAfter(HTMLEditorField::create('ExtraContent'), 'Content');
$gridField = new GridField('FeatureItems', 'FeatureItems', $this->FeatureItems()->sort(array('Sort' => 'ASC', 'Archived' => 'ASC')), $config = GridFieldConfig_RelationEditor::create());
$gridField->setModelClass('FeatureItem');
$fields->addFieldToTab('Root.Features', $gridField);
$config->addComponent(new GridFieldOrderableRows());
} else {
if ($this->ClassName === "CalendarPage") {
$content = $fields->dataFieldByName('Content');
$content->addExtraClass('no-pagebreak');
$events = Event::get()->sort(array('StartDateTime' => 'Desc'))->filterByCallback(function ($record) {
return !$record->getIsPastEvent();
});
$gridField = new GridField('Event', 'Upcoming Events', $events, $config = GridFieldConfig_RecordEditor::create());
$gridField->setModelClass('Event');
$dataColumns = $config->getComponentByType('GridFieldDataColumns');
$dataColumns->setDisplayFields(array('Title' => 'Title', 'StartDateTime' => 'Date and Time', 'DatesAndTimeframe' => 'Presentation String'));
$fields->addFieldToTab('Root.UpcomingEvents', $gridField);
}
}
return $fields;
}
示例15: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
// Create a default configuration for the new GridField, allowing record deletion
$config = GridFieldConfig_RecordEditor::create();
// Set the names and data for our gridfield columns
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Title' => 'Title', 'StartTime' => 'Start Time', 'EndTime' => 'End Time'));
// Create a gridfield to hold the calendar event relationship
$calendarEventsGridField = new GridField('CalendarEvents', 'Calendar Events', $this->CalendarEvents(), $config);
// Create a tab named "Calendar" and add our field to it
$fields->addFieldToTab('Root.Calendar', $calendarEventsGridField);
// Create a default configuration for the location GridField, allowing record deletion
$locationsConfig = GridFieldConfig::create();
$locationsConfig->addComponent(new GridFieldButtonRow('before'));
$locationsConfig->addComponent(new GridFieldToolbarHeader());
$locationsConfig->addComponent(new GridFieldTitleHeader());
$locationsConfig->addComponent(new GridFieldEditableColumns());
$locationsConfig->addComponent(new GridFieldDeleteAction());
$locationsConfig->addComponent(new GridFieldAddNewInlineButton());
// Create a gridfield to hold the locations
$locationsGridField = new GridField('CalendarLocations', 'Calendar Locations', $this->CalendarLocations(), $locationsConfig);
// Create a tab named "Locations" and add our field to it
$fields->addFieldToTab('Root.Locations', $locationsGridField);
return $fields;
}