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); } }
/** * @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; }
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; }
/** * @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; }
/** * @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); }
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; }
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; }
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); }
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; }
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; }
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; }
/** * 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; }
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()); } }
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; }
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; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeFieldFromTab('Root.Main', 'Content', true); $fields->addFieldsToTab('Root.Fields', array(new GridField('Fields', _t('MemberProfiles.PROFILEFIELDS', 'Account Fields'), $this->Fields(), $grid = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldAddNewButton')))); return $fields; }
/** * @return FieldList */ public function getCMSFields() { $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main'))); $f->addFieldToTab('Root.Main', new TextField('Name', 'Name')); $f->addFieldToTab('Root.Main', $ddl = new DropdownField('ListType', 'ListType', $this->dbObject('ListType')->enumValues())); $f->addFieldToTab('Root.Main', $ddl2 = new DropdownField('CategoryID', 'Category', PresentationCategory::get()->filter('SummitID', $_REQUEST['SummitID'])->map('ID', 'Title'))); $ddl->setEmptyString('-- Select List Type --'); $ddl2->setEmptyString('-- Select Track --'); if ($this->ID > 0) { $config = GridFieldConfig_RecordEditor::create(25); $config->addComponent(new GridFieldAjaxRefresh(1000, false)); $config->addComponent(new GridFieldPublishSummitEventAction()); $config->removeComponentsByType('GridFieldDeleteAction'); $config->removeComponentsByType('GridFieldAddNewButton'); $config->addComponent($bulk_summit_types = new GridFieldBulkActionAssignSummitTypeSummitEvents()); $bulk_summit_types->setTitle('Set Summit Types'); $result = DB::query("SELECT DISTINCT SummitEvent.*, Presentation.*\nFROM SummitEvent\nINNER JOIN Presentation ON Presentation.ID = SummitEvent.ID\nINNER JOIN SummitSelectedPresentation ON SummitSelectedPresentation.PresentationID = Presentation.ID\nINNER JOIN SummitSelectedPresentationList ON SummitSelectedPresentation.SummitSelectedPresentationListID = {$this->ID}\nORDER BY SummitSelectedPresentation.Order ASC\n"); $presentations = new ArrayList(); foreach ($result as $row) { $presentations->add(new Presentation($row)); } $gridField = new GridField('SummitSelectedPresentations', 'Selected Presentations', $presentations, $config); $gridField->setModelClass('Presentation'); $f->addFieldToTab('Root.Main', $gridField); } return $f; }
function getModularCMSFields($relationName = 'Modules', $title = 'Content Modules') { $fields = array(); $GLOBALS['_CONTENT_MODULE_PARENT_PAGEID'] = $this->owner->ID; $area = $this->owner->obj($relationName); if ($area && $area->exists()) { $fields[] = HeaderField::create($relationName . 'Header', $title, 2); $fields[] = GridField::create($relationName, $title, $area->Modules(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldOrderableRows('SortOrder'))->removeComponentsByType('GridFieldAddNewButton')->addComponent($add = new GridFieldAddNewMultiClass())); if (($allowed_modules = $this->owner->Config()->get('allowed_modules')) && is_array($allowed_modules) && count($allowed_modules)) { if (isset($allowed_modules[$relationName])) { $add->setClasses($allowed_modules[$relationName]); } else { $add->setClasses($allowed_modules); } } else { // Remove the base "ContentModule" from allowed modules. $classes = array_values(ClassInfo::subclassesFor('ContentModule')); sort($classes); if (($key = array_search('ContentModule', $classes)) !== false) { unset($classes[$key]); } $add->setClasses($classes); } } else { $fields[] = LiteralField::create('SaveFirstToAddModules', '<div class="message">You must save first before you can add modules.</div>'); } return $fields; }
public function getCMSFields() { $self = $this; $this->beforeUpdateCMSFields(function ($f) use($self) { Requirements::javascript('event_calendar/javascript/calendar_cms.js'); $f->addFieldToTab("Root.Main", TextField::create("Location", _t('Calendar.LOCATIONDESCRIPTION', 'The location for this event')), 'Content'); $dt = _t('CalendarEvent.DATESANDTIMES', 'Dates and Times'); $recursion = _t('CalendarEvent.RECURSION', 'Recursion'); $f->addFieldToTab("Root.{$dt}", GridField::create("DateTimes", _t('Calendar.DATETIMEDESCRIPTION', 'Add dates for this event'), $self->DateTimes(), GridFieldConfig_RecordEditor::create())); $f->addFieldsToTab("Root.{$recursion}", array(new CheckboxField('Recursion', _t('CalendarEvent.REPEATEVENT', 'Repeat this event')), new OptionsetField('CustomRecursionType', _t('CalendarEvent.DESCRIBEINTERVAL', 'Describe the interval at which this event recurs.'), array('1' => _t('CalendarEvent.DAILY', 'Daily'), '2' => _t('CalendarEvent.WEEKLY', 'Weekly'), '3' => _t('CalendarEvent.MONTHLY', 'Monthly'))))); $f->addFieldToTab("Root.{$recursion}", $dailyInterval = new FieldGroup(new LabelField($name = "every1", $title = _t("CalendarEvent.EVERY", "Every ")), new DropdownField('DailyInterval', '', array_combine(range(1, 10), range(1, 10))), new LabelField($name = "days", $title = _t("CalendarEvent.DAYS", " day(s)")))); $f->addFieldToTab("Root.{$recursion}", $weeklyInterval = new FieldGroup(new LabelField($name = "every2", $title = _t("CalendarEvent.EVERY", "Every ")), new DropdownField('WeeklyInterval', '', array_combine(range(1, 10), range(1, 10))), new LabelField($name = "weeks", $title = _t("CalendarEvent.WEEKS", " weeks")))); $f->addFieldToTab("Root.{$recursion}", new CheckboxSetField('RecurringDaysOfWeek', _t('CalendarEvent.ONFOLLOWINGDAYS', 'On the following day(s)...'), DataList::create("RecurringDayOfWeek")->map("ID", "Title"))); $f->addFieldToTab("Root.{$recursion}", $monthlyInterval = new FieldGroup(new LabelField($name = "every3", $title = _t("CalendarEvent.EVERY", "Every ")), new DropdownField('MonthlyInterval', '', array_combine(range(1, 10), range(1, 10))), new LabelField($name = "months", $title = _t("CalendarEvent.MONTHS", " month(s)")))); $f->addFieldsToTab("Root.{$recursion}", array(new OptionsetField('MonthlyRecursionType1', '', array('1' => _t('CalendarEvent.ONTHESEDATES', 'On these date(s)...'))), new CheckboxSetField('RecurringDaysOfMonth', '', DataList::create("RecurringDayOfMonth")->map("ID", "Value")), new OptionsetField('MonthlyRecursionType2', '', array('1' => _t('CalendarEvent.ONTHE', 'On the...'))))); $f->addFieldToTab("Root.{$recursion}", $monthlyIndex = new FieldGroup(new DropdownField('MonthlyIndex', '', array('1' => _t('CalendarEvent.FIRST', 'First'), '2' => _t('CalendarEvent.SECOND', 'Second'), '3' => _t('CalendarEvent.THIRD', 'Third'), '4' => _t('CalendarEvent.FOURTH', 'Fourth'), '5' => _t('CalendarEvent.LAST', 'Last'))), new DropdownField('MonthlyDayOfWeek', '', DataList::create("RecurringDayOfWeek")->map("Value", "Title")), new LabelField($name = "ofthemonth", $title = _t("CalendarEvent.OFTHEMONTH", " of the month.")))); $f->addFieldToTab("Root.{$recursion}", GridField::create("Exceptions", _t('CalendarEvent.ANYEXCEPTIONS', 'Any exceptions to this pattern? Add the dates below.'), $self->Exceptions(), GridFieldConfig_RecordEditor::create())); $dailyInterval->addExtraClass('dailyinterval'); $weeklyInterval->addExtraClass('weeklyinterval'); $monthlyInterval->addExtraClass('monthlyinterval'); $monthlyIndex->addExtraClass('monthlyindex'); }); $f = parent::getCMSFields(); return $f; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Features'); $fields->removeByName('ExtraContent'); $regContent = $fields->dataFieldByName('RegistrationContent'); $afterContent = $fields->dataFieldByName('AfterRegistrationContent'); $profileContent = $fields->dataFieldByName('ProfileContent'); $regContent->addExtraClass('no-pagebreak'); $afterContent->addExtraClass('no-pagebreak'); $profileContent->addExtraClass('no-pagebreak'); $fields->insertAfter(TextareaField::create('ApprovalEmailTemplate', 'Approval Email Template'), 'EmailTemplate'); $fields->insertAfter(TextField::create('ApprovalEmailSubject', 'Approval Email Subject'), 'EmailTemplate'); $fields->insertAfter(TextareaField::create('ExpiryReminderEmailTemplate', 'Expiry Reminder Email Template'), 'ApprovalEmailTemplate'); $fields->insertAfter(TextField::create('ExpiryReminderEmailSubject', 'Expiry Reminder Email Subject'), 'ApprovalEmailTemplate'); $fields->insertAfter(TextareaField::create('ExpiryEmailTemplate', 'Expiry Email Template'), 'ExpiryReminderEmailTemplate'); $fields->insertAfter(TextField::create('ExpiryEmailSubject', 'Expiry Email Subject'), 'ExpiryReminderEmailTemplate'); $fields->addFieldToTab('Root.Members', LiteralField::create('MembersNote', '<p class="message"><strong>Note:</strong> This list has been filtered to include current and pending members only. Use the Members admin area for handling expired memberships and non-member website users.</p>')); $members = Member::get()->exclude(array('MembershipStatus' => 'Not applied'))->exclude(array('MembershipStatus' => 'Expired'))->sort(array('ExpiryDate' => 'ASC')); $gridField = new GridField('Members', 'NZLARP Members', $members, $config = GridFieldConfig_RecordEditor::create()); $gridField->setModelClass('Member'); $columns = $config->getComponentByType('GridFieldDataColumns'); $columns->setFieldFormatting(array('LastEdited' => function ($value, $item) { return $item->LastEditedNice(); })); $columns->setDisplayFields(array('getName' => 'Name', 'Region.Title' => 'Region', 'MembershipStatus' => 'Status', 'ExpiryDate' => 'Expires', 'LastEdited' => 'Last Activity')); $fields->addFieldToTab('Root.Members', $gridField); $config->getComponentByType('GridFieldPaginator')->setItemsPerPage(200); return $fields; }
/** * Contructor * @param type $controller * @param type $name */ function __construct($controller, $name) { //Administering calendars if (CalendarConfig::subpackage_enabled('calendars')) { //Configuration for calendar grid field $gridCalendarConfig = GridFieldConfig_RecordEditor::create(); $gridCalendarConfig->removeComponentsByType('GridFieldDataColumns'); $gridCalendarConfig->addComponent($dataColumns = new GridFieldDataColumns(), 'GridFieldEditButton'); $c = singleton('Calendar'); $summaryFields = $c->summaryFields(); //$summaryFields = array( // 'Title' => 'Title', // //'SubscriptionOptIn' => 'Opt In', // //'Shaded' => 'Shaded' //); $s = CalendarConfig::subpackage_settings('calendars'); //show shading info in the gridfield if ($s['shading']) { $summaryFields['Shaded'] = 'Shaded'; } $dataColumns->setDisplayFields($summaryFields); //settings for the case that colors are enabled if ($s['colors']) { $dataColumns->setFieldFormatting(array("Title" => '<div style=\\"height:20px;width:20px;display:inline-block;vertical-align:middle;margin-right:6px;background:$Color\\"></div> $Title')); } $GridFieldCalendars = new GridField('Calendars', '', PublicCalendar::get(), $gridCalendarConfig); $fields = new FieldList($GridFieldCalendars); $actions = new FieldList(); $this->addExtraClass('CalendarsForm'); parent::__construct($controller, $name, $fields, $actions); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Profiles', GridField::create('Profiles', 'Profiles on this page', $this->Profiles(), GridFieldConfig_RecordEditor::create())); $fields->addFieldToTab('Root.Main', TextField::create('Subheading', 'Page Subheading'), 'Content'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.EnquiryForm', HeaderField::create('Enquiry Form Setup', 2)); $gridFieldConfig = GridFieldConfig_RecordEditor::create(100); $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder')); /* Unset field-sorting hack */ $gridFieldConfig->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('FieldName' => 'FieldNameNoSorting', 'FieldType' => 'FieldTypeNoSorting')); $gridField = GridField::create('EnquiryFormFields', false, $this->EnquiryFormFields(), $gridFieldConfig); $fields->addFieldToTab('Root.EnquiryForm', $gridField); $email_settings = array(EmailField::create('EmailTo', 'Send email to'), EmailField::create('EmailFrom', 'Send email from')->setRightTitle('For example website@yourdomain.com'), TextField::create('EmailSubject', 'Email subject'), HeaderField::create('Message on website once completed', 5), HTMLEditorField::create('EmailSubmitCompletion', '')->setRows(10), EmailField::create('EmailBcc', 'Send BCC copy to (optional)')->setRightTitle('If you would like a copy of the enquiry to be sent elsewhere, fill that in here.'), TextField::create('EmailSubmitButtonText', 'Submit button text')); $toggleSettings = ToggleCompositeField::create('FormSettings', 'Enquiry Form Settings', $email_settings); $fields->addFieldsToTab('Root.EnquiryForm', $toggleSettings); $spam_settings = array(); array_push($spam_settings, DropdownField::create('AddCaptcha', 'Add captcha image (optional)', array(0 => 'No', 1 => 'Yes'))->setRightTitle('You can optionally enable an anti-spam "captcha" image. This adds a small image with 4 random numbers which needs to be filled in correctly.')); if (!$this->CaptchaText) { $this->CaptchaText = 'Verification Image'; } array_push($spam_settings, TextField::create('CaptchaText', 'Field name')); array_push($spam_settings, TextField::create('CaptchaHelp', 'Captcha help (optional)')->setRightTitle('If you would like to explain what the captcha is, please explain briefly what it is. This is only used if you have selected to add the captcha image.')); $toggleSpam = ToggleCompositeField::create('SpamSettings', 'Anti-Spam Settings', $spam_settings); $fields->addFieldsToTab('Root.EnquiryForm', $toggleSpam); return $fields; }
public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab("Root.Orders", GridField::create("OrderNotifications", "Order status notifications", $this->owner->OrderNotifications(), GridFieldConfig_RecordEditor::create())); $fields->addFieldToTab("Root.Orders", HTMLEditorField::create("OrdersHeader", _t("Orders.QuoteInvoiceHeader", "Quote and Invoice Header"))); $fields->addFieldToTab("Root.Orders", HTMLEditorField::create("QuoteFooter")); $fields->addFieldToTab("Root.Orders", HTMLEditorField::create("InvoiceFooter")); }
public function getCMSFields() { $fields = new FieldList(); $_REQUEST['entity_survey'] = 1; $fields->add(new TextField('EntityName', 'Entity Name (Without Spaces)')); $fields->add(new CheckboxField('Enabled', 'Is Enabled?')); $fields->add(new CheckboxField('UseTeamEdition', 'Allow Team Edition?')); $fields->add(new HiddenField('CreatedByID', 'CreatedByID', Member::currentUserID())); $fields->add(new HiddenField('ParentID', 'ParentID')); //steps if ($this->ID > 0) { $_REQUEST['survey_template_id'] = $this->ID; // steps $config = GridFieldConfig_RecordEditor::create(); $config->removeComponentsByType('GridFieldAddNewButton'); $multi_class_selector = new GridFieldAddNewMultiClass(); $multi_class_selector->setClasses(array('SurveyRegularStepTemplate' => 'Regular Step')); $config->addComponent($multi_class_selector); $config->addComponent(new GridFieldSortableRows('Order')); $gridField = new GridField('Steps', 'Steps', $this->Steps(), $config); $fields->add($gridField); $config = GridFieldConfig_RecordEditor::create(); $config->removeComponentsByType('GridFieldAddNewButton'); $multi_class_selector = new GridFieldAddNewMultiClass(); $migration_mapping_types = array('OldDataModelSurveyMigrationMapping' => 'Old Survey Data Mapping'); $multi_class_selector->setClasses($migration_mapping_types); $config->addComponent($multi_class_selector); $gridField = new GridField('MigrationMappings', 'Migration Mappings', $this->MigrationMappings(), $config); $fields->add($gridField); } return $fields; }
public function getEditForm($id = null, $fields = null) { $classname = $this->modelClass; $list = $classname::get(); $listField = GridField::create($this->sanitiseClassName($this->modelClass), false, $list, $fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length'))->removeComponentsByType('GridFieldFilterHeader')); if (!$this->stat('enable_sorting')) { $summary_fields = Config::inst()->get($this->modelClass, 'summary_fields'); $sorting = array(); foreach ($summary_fields as $col) { $sorting[$col] = 'FieldNameNoSorting'; } $fieldConfig->getComponentByType('GridFieldSortableHeader')->setFieldSorting($sorting); } // Validation if (singleton($this->modelClass)->hasMethod('getCMSValidator')) { $detailValidator = singleton($this->modelClass)->getCMSValidator(); $listField->getConfig()->getComponentByType('GridFieldDetailForm')->setValidator($detailValidator); } $form = new Form($this, 'EditForm', new FieldList($listField), new FieldList()); $form->addExtraClass('cms-edit-form cms-panel-padded center'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $editFormAction = Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm'); $form->setFormAction($editFormAction); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $this->extend('updateEditForm', $form); return $form; }
public function getCMSFields() { $fields = new FieldList(); $fields->push(new TabSet("Root", new Tab("Main", TextField::create("Title", "Title"), GridField::create("Slides", "Nivo Slide", $this->Slides(), GridFieldConfig_RecordEditor::create())), new Tab("Advanced", DropdownField::create("Theme", "Theme", self::get_all_themes()), DropdownField::create("Effect", "Effect", $this->dbObject("Effect")->enumValues()), NumericField::create("AnimationSpeed", "Animation Speed")->setDescription("Animation speed in milliseconds."), NumericField::create("PauseTime", "Pause Time")->setDescription("Pause time on each frame in milliseconds."), TextField::create("PrevText", "Previous Text"), TextField::create("NextText", "Next Text"), NumericField::create("Slices", "Slices")->setDescription("Number of slices for slice animation effects."), NumericField::create("BoxCols", "Box Columns")->setDescription("Number of box columns for box animation effects."), NumericField::create("BoxRows", "Box Rows")->setDescription("Number of box rows for box animation effects."), NumericField::create("StartSlide", "Start Slide")->setDescription("Slide to start on (0 being the first)."), HeaderField::create("ControlHeading", "Control Options", 4), CompositeField::create(array(CheckboxField::create("DirectionNav", "Display Direction Navigation?"), CheckboxField::create("ControlNav", "Display Control Navigation?"), CheckboxField::create("ControlNavThumbs", "Use thumbnails for control nav?"), CheckboxField::create("PauseOnHover", "Stop the animation whilst hovering?"), CheckboxField::create("ManualAdvance", "Force manual transition?"), CheckboxField::create("RandomStart", "Random Start?")))))); $fields->extend("updateCMSFields", $fields); return $fields; }
/** * Get CMS fields * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('TeamMembers'); $fields->addFieldToTab('Root.Main', GridField::create('TeamMembers', 'Team Members', $this->TeamMembers(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldSortableRows('SortOrder')))); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); // TODO: Change the autogenerated stub $fields->addFieldsToTab("Root.Regions", GridField::create('Regions', 'Regions on this page', $this->Regions(), GridFieldConfig_RecordEditor::create())); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Departments', GridField::create('Department', 'Departments', Department::get()->sort('Title'), GridFieldConfig_RecordEditor::create())); $fields->addFieldToTab('Root.Roles', GridField::create('Role', 'Roles', Role::get()->sort('Title'), GridFieldConfig_RecordEditor::create())); return $fields; }