public function __construct($name, $title = null, SS_List $dataList = null) { parent::__construct($name, $title, $dataList); $config = new GridFieldConfig_RecordEditor(); $config->removeComponentsByType('GridFieldDeleteAction'); $config->removeComponentsByType('GridFieldDetailForm'); $config->addComponent(new PageHolderGridFieldDetailForm()); $config->addComponent(new GridFieldPageHistoryButton(), 'GridFieldPageCount'); $this->setConfig($config); }
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); } }
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; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->fieldByName('Root')->removeByName("DistanceFares"); if ($this->isInDB()) { $fields->addFieldToTab("Root.Main", $gridfield = GridField::create("DistanceFares", "Fares", $this->DistanceFares(), $config = new GridFieldConfig_RecordEditor())); $config->removeComponentsByType("GridFieldDataColumns"); $config->removeComponentsByType("GridFieldEditButton"); $config->removeComponentsByType("GridFieldDeleteAction"); $config->removeComponentsByType("GridFieldAddNewButton"); $config->addComponent($cols = new GridFieldEditableColumns()); $config->addComponent(new GridFieldDeleteAction()); $config->addComponent($addnew = new GridFieldAddNewInlineButton()); $addnew->setTitle($addnew->getTitle() . " Fare"); if ($greatest = $this->greatestCostDistance()) { $fields->insertAfter(LiteralField::create("costnote", "<p class=\"message\">Distances beyond the greatest specified distance will be cost " . $this->greatestCostDistance()->dbObject("Cost")->Nice() . " (the most expensive fare)</p>"), "DistanceFares"); } } return $fields; }
public function getCMSFields() { $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID; $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main'))); $f->addFieldToTab('Root.Main', new TextField('Title', 'Title')); $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description')); $f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Short Description')); $f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end(); $f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?')); $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID')); $f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date')); $date->getDateField()->setConfig('showcalendar', true); $date->setConfig('dateformat', 'dd/MM/yyyy'); $f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date')); $date->getDateField()->setConfig('showcalendar', true); $date->setConfig('dateformat', 'dd/MM/yyyy'); $locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation')); $locations_source = array(); foreach ($locations as $l) { $locations_source[$l->ID] = $l->getFullName(); } $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source)); $ddl_location->setEmptyString('-- Select a Location --'); $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type'))); $ddl_location->setEmptyString('-- Select a Event Type --'); $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID')); if ($this->ID > 0) { // summits types $config = new GridFieldConfig_RelationEditor(100); $config->removeComponentsByType('GridFieldEditButton'); $config->removeComponentsByType('GridFieldAddNewButton'); $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter'); $completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id)); $summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config); $f->addFieldToTab('Root.Main', $summit_types); // sponsors $config = new GridFieldConfig_RelationEditor(100); $config->removeComponentsByType('GridFieldEditButton'); $config->removeComponentsByType('GridFieldAddNewButton'); $sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config); $f->addFieldToTab('Root.Sponsors', $sponsors); // feedback $config = new GridFieldConfig_RecordEditor(100); $config->removeComponentsByType('GridFieldAddNewButton'); $feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config); $f->addFieldToTab('Root.Feedback', $feedback); } return $f; }
public function getCMSFields() { Requirements::customScript("\n jQuery( document ).ready(function() {\n jQuery('body').on('change','#Form_ItemEditForm_RSVPTemplateID',\n function(){\n jQuery('#Form_ItemEditForm_action_save').click();\n }\n );\n });"); $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID; $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main'))); $f->addFieldToTab('Root.Main', new TextField('Title', 'Title')); $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description')); $f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Abstract')); $f->addFieldToTab('Root.Main', new TextField('HeadCount', 'HeadCount')); $f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end(); $f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?')); $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID')); $f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date')); $date->getDateField()->setConfig('showcalendar', true); $date->setConfig('dateformat', 'dd/MM/yyyy'); $f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date')); $date->getDateField()->setConfig('showcalendar', true); $date->setConfig('dateformat', 'dd/MM/yyyy'); $f->addFieldsToTab('Root.Main', new ReadonlyField('AvgFeedbackRate', 'AvgFeedbackRate')); $locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation')); $locations_source = array(); foreach ($locations as $l) { $locations_source[$l->ID] = $l->getFullName(); } $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source)); $ddl_location->setEmptyString('-- Select a Location --'); $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type'))); $ddl_location->setEmptyString('-- Select a Event Type --'); $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID')); if ($this->ID > 0) { // summits types $config = new GridFieldConfig_RelationEditor(100); $config->removeComponentsByType('GridFieldEditButton'); $config->removeComponentsByType('GridFieldAddNewButton'); $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter'); $completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id)); $summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config); $f->addFieldToTab('Root.Main', $summit_types); // sponsors $config = new GridFieldConfig_RelationEditor(100); $config->removeComponentsByType('GridFieldEditButton'); $config->removeComponentsByType('GridFieldAddNewButton'); $sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config); $f->addFieldToTab('Root.Sponsors', $sponsors); // feedback $config = new GridFieldConfig_RecordEditor(100); $config->removeComponentsByType('GridFieldAddNewButton'); $config->addComponent(new GridFieldAjaxRefresh(1000, false)); $feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config); $f->addFieldToTab('Root.Feedback', $feedback); // rsvp $f->addFieldsToTab('Root.RSVP', new TextField('RSVPLink', 'RSVP External Link')); $rsvp_template = new DropdownField('RSVPTemplateID', 'Select a Template', RSVPTemplate::get()->filter('SummitID', $summit_id)->map()); $rsvp_template->setEmptyString('-- View All Templates --'); $f->addFieldToTab('Root.RSVP', LiteralField::create('AddNew', 'Or add a new custom RSVP Configuration')); $f->addFieldToTab('Root.RSVP', $rsvp_template); $f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserNumber', 'Max # Number')); $f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserWaitListNumber', 'Max # Wait List')); $f->addFieldToTab('Root.RSVP', $rsvp_template); if ($this->RSVPTemplate()->exists()) { $config = new GridFieldConfig_RecordEditor(100); $config->removeComponentsByType('GridFieldAddNewButton'); $config->addComponent(new GridFieldAjaxRefresh(1000, false)); $rsvps = new GridField('RSVPSubmissions', 'RSVP Submissions', $this->RSVPSubmissions(), $config); $f->addFieldToTab('Root.RSVP', $rsvps); } } if ($this->ID > 0) { $_REQUEST['SummitEventID'] = $this->ID; } return $f; }