public function updateCMSFields(FieldList $fields) { // Deal with customisations $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t("CustomisableProduct.AddCustomisationList", "Add Customisation List")); $custom_config = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), $add_button, new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm()); $fields->addFieldTotab("Root.CustomProducts", GridField::create('ProductCustomisationLists', '', $this->owner->ProductCustomisationLists(), $custom_config)); }
public function enableCreate($button_title = null) { $this->addDetailForm(); $button = new GridFieldAddNewButton(); if ($button_title) { $button->setButtonName($button_title); } $this->config->addComponent($button); return $this; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Root.Customisations"); $fields->addFieldToTab('Root', new Tab('Customisations', 'Customisations'), 'Settings'); // Deal with customisations $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName('Add Customisation'); $custom_config = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), $add_button, new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldOrderableRows('Sort')); $custom_field = GridField::create('Customisations', '', $this->Customisations(), $custom_config); $fields->addFieldToTab('Root.Customisations', $custom_field); return $fields; }
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $params = $this->request->requestVar('q'); if ($this->modelClass == 'FilterGroup') { $gridField = $form->Fields()->fieldByName('FilterGroup'); $field_config = $gridField->getConfig(); // Re add creation button and update grid field $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t("Filterable.AddFilter", "Add Filter")); $field_config->removeComponentsByType('GridFieldExportButton')->removeComponentsByType('GridFieldPrintButton')->removeComponentsByType('GridFieldAddNewButton')->addComponents($add_button, GridFieldOrderableRows::create('Sort')); } return $form; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Root.Customisations"); // Only add fields if the object exists if ($this->ID) { $fields->addFieldToTab('Root', new Tab('Customisations', 'Customisations'), 'Settings'); // Deal with customisations $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t("CustomisableProduct.AddCustomisation", "Add Customisation")); $custom_config = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), $add_button, new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldOrderableRows('Sort')); $fields->addFieldsToTab('Root.Customisations', array(DropdownField::create("CustomisationListID", _t("CustomisableProduct.UseCustomisationList", "Use a Customisation List"), ProductCustomisationList::get()->map())->setEmptyString(_t("CustomisableProduct.SelectList", "Select List")), GridField::create('Customisations', '', $this->Customisations(), $custom_config))); } return $fields; }
public function updateCMSFields(FieldList $fields) { if ($this->owner->ShowMap) { $maps_field = new GridField('Maps', '', $this->owner->Maps(), $config = GridFieldConfig_RecordEditor::create()); $config->addComponent(new GridFieldOrderableRows('Sort')); // Add creation button if member has create permissions if ($this->owner->canCreate()) { $config->removeComponentsByType('GridFieldAddNewButton'); $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t("GoogleMaps.AddGoogleMap", "Add Google Map")); $config->addComponent($add_button); } $fields->addFieldToTab('Root.Maps', $maps_field); } return $fields; }
public function updateCMSFields(FieldList $fields) { if ($this->owner->ShowTimeline) { // Create add button $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName('Add Event'); // Add timeline editor $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($add_button); $timeline_table = GridField::create('Events', false, $this->owner->Events(), $grid_config); $fields->addFieldToTab('Root.Timeline', $timeline_table); } else { $fields->removeByName('Events'); } $fields->removeByName('ShowTimeline'); parent::updateCMSFields($fields); }
public function updateCMSFields(FieldList $fields) { if ($this->owner->ShowMap) { $maps_field = new GridField('Maps', '', $this->owner->Maps(), GridFieldConfig_RecordEditor::create()); // Tidy up category config and remove default add button $field_config = $maps_field->getConfig(); $field_config->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldSortableRows('Sort')); // Add creation button if member has create permissions if ($this->owner->canCreate()) { $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName('Add Google Map'); $field_config->addComponent($add_button); } $fields->addFieldToTab('Root.Maps', $maps_field); } return $fields; }
public function updateCMSFields(FieldList $fields) { if ($this->owner->ShowCarousel) { // Create add button $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName('Add Slide'); // Add carousel editor $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($add_button); $carousel_table = GridField::create('Slides', false, $this->owner->Slides(), $grid_config); $fields->addFieldToTab('Root.Carousel', $carousel_table); } else { $fields->removeByName('Slides'); } $fields->removeByName('ShowCarousel'); $fields->removeByName('CarouselWidth'); $fields->removeByName('CarouselHeight'); parent::updateCMSFields($fields); }
public function updateCMSFields(FieldList $fields) { if ($this->owner->ShowOrbit) { // Create add button $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName('Add Slide'); // Add Orbit editor $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent($add_button); $orbit_table = GridField::create('Slides', false, $this->owner->Slides()->sort('Sort DESC'), $grid_config); $fields->addFieldToTab('Root.Orbit', $orbit_table); } else { $fields->removeByName('Slides'); } $fields->removeByName('ShowOrbit'); $fields->removeByName('OrbitWidth'); $fields->removeByName('OrbitHeight'); parent::updateCMSFields($fields); }
public function updateCMSFields(Fieldlist $fields) { // If Users Requests Carousel On Page if ($this->owner->ShowCarousel) { // Create Add Image Button $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t('CarouselPage.ADDIMAGE', 'Add Image')); // Add Carousel Editor $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent($add_button); // Table to Display Current Carousel Images $carousel_table = GridField::create('CarouselElements', false, $this->owner->CarouselElements()->sort('Sort ASC'), $grid_config); // Creates a tab on CMS to manage Carousel on $fields->addFieldToTab('Root.' . _t('CarouselPage.CAROUSELTABLABEL', 'Carousel'), $carousel_table); } else { $fields->removeByName('CarouselElements'); } // By default carousel settings do not appear $fields->removeByName('ShowCarousel'); $fields->removeByName('CarouselWidth'); $fields->removeByName('CarouselHeight'); parent::updateCMSFields($fields); }
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $fields = $form->Fields(); if ($this->modelClass == 'CustomMenuHolder') { $gridField = $fields->fieldByName('CustomMenuHolder'); // Tidy up category config and remove default add button $field_config = $gridField->getConfig(); $field_config->removeComponentsByType('GridFieldExportButton')->removeComponentsByType('GridFieldPrintButton')->removeComponentsByType('GridFieldAddNewButton'); // Add creation button if member has create permissions if (Permission::check('ADMIN') || Permission::check('MENU_CREATE')) { $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t('CustomMenus.AddMenu', 'Add Menu')); $field_config->addComponent($add_button); } // Update list of items for subsite (if used) if (class_exists('Subsite')) { $list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID())); $gridField->setList($list); } } return $form; }
public function getHTMLFragments($gridField) { $record = $gridField->getRecord(); if (!$record->exists() || !$record->isInDB()) { return parent::getHTMLFragments($gridField); //use parent add button } $singleton = singleton($gridField->getModelClass()); if (!$singleton->canCreate()) { return array(); } if (!$this->buttonName) { // provide a default button name, can be changed by calling {@link setButtonName()} on this component $objectName = $singleton->i18n_singular_name(); $this->buttonName = _t('GridField.Edit', 'Edit {name}', array('name' => $objectName)); } $data = new ArrayData(array('NewLink' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit'), 'ButtonName' => $this->buttonName)); return array($this->targetFragment => $data->renderWith('GridFieldAddNewbutton')); }
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $params = $this->request->requestVar('q'); // Bulk manager $manager = new GridFieldBulkManager(); $manager->removeBulkAction("unLink"); $manager->addBulkAction('disable', 'Disable', 'CatalogueProductBulkAction'); $manager->addBulkAction('enable', 'Enable', 'CatalogueProductBulkAction'); if ($this->modelClass == 'Product') { $gridField = $form->Fields()->fieldByName('Product'); $field_config = $gridField->getConfig(); // Re add creation button and update grid field $add_button = new GridFieldAddNewButton('buttons-before-left'); $add_button->setButtonName(_t("CatalogueAdmin.AddProduct", "Add Product")); $field_config->removeComponentsByType('GridFieldPrintButton')->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDetailForm')->addComponents($add_button, $manager, new CatalogueEnableDisableDetailForm()); // Set the page length $field_config->getComponentByType('GridFieldPaginator')->setItemsPerPage($this->config()->product_page_length); // Update list of items for subsite (if used) if (class_exists('Subsite')) { $list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID())); $gridField->setList($list); } } // Alterations for Hiarachy on product cataloge if ($this->modelClass == 'Category') { $gridField = $form->Fields()->fieldByName('Category'); // Set custom record editor $record_editor = new CatalogueEnableDisableDetailForm(); $record_editor->setItemRequestClass('CatalogueCategory_ItemRequest'); // Create add button and update grid field $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName(_t("CatalogueAdmin.AddCategory", "Add Category")); // Tidy up category config $field_config = $gridField->getConfig(); $field_config->removeComponentsByType('GridFieldExportButton')->removeComponentsByType('GridFieldPrintButton')->removeComponentsByType('GridFieldDetailForm')->removeComponentsByType('GridFieldAddNewButton')->addComponents($record_editor, $add_button, $manager, GridFieldOrderableRows::create('Sort')); // Set the page length $field_config->getComponentByType('GridFieldPaginator')->setItemsPerPage($this->config()->category_page_length); // Setup hierarchy view $parentID = $this->request->requestVar('ParentID'); if ($parentID) { $field_config->addComponent(GridFieldLevelup::create($parentID)->setLinkSpec('?ParentID=%d')->setAttributes(array('data-pjax' => 'ListViewForm,Breadcrumbs'))); } // Find data colums, so we can add link to view children $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns'); // Don't allow navigating into children nodes on filtered lists $fields = array('Title' => 'Title', 'URLSegment' => 'URLSegement'); if (!$params) { $fields = array_merge(array('listChildrenLink' => ''), $fields); } $columns->setDisplayFields($fields); $columns->setFieldCasting(array('Title' => 'HTMLText', 'URLSegment' => 'Text')); $controller = $this; $columns->setFieldFormatting(array('listChildrenLink' => function ($value, &$item) use($controller) { return sprintf('<a class="list-children-link" data-pjax-target="ListViewForm" href="%s?ParentID=%d">►</a>', $controller->Link(), $item->ID); })); // Update list of items for subsite (if used) if (class_exists('Subsite')) { $list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID())); $gridField->setList($list); } } $this->extend("updateEditForm", $form); return $form; }
/** * Setup a gridfield for the deployment steps * * @param FieldList $fields */ protected function setDeployStepsFields(&$fields, $releaseSteps) { if (!$releaseSteps) { return; } $releaseSteps->getConfig()->addComponent(new GridFieldSortableRows('Sort')); $releaseSteps->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter'); $releaseSteps->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $releaseSteps->getConfig()->removeComponentsByType('GridFieldPageCount'); $addNewRelease = new GridFieldAddNewButton('toolbar-header-right'); $addNewRelease->setButtonName('Add'); $releaseSteps->getConfig()->addComponent($addNewRelease); $fields->addFieldToTab("Root.Release steps", $releaseSteps); }
/** * Setup a gridfield for the environment configs * * @param FieldList $fields * @param $environments * @return void */ protected function setEnvironmentFields(&$fields, $environments) { if (!$environments) { return; } $environments->getConfig()->addComponent(new GridFieldAddNewMultiClass()); $environments->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $environments->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter'); $environments->getConfig()->removeComponentsByType('GridFieldDeleteAction'); $environments->getConfig()->removeComponentsByType('GridFieldPageCount'); if (Config::inst()->get('DNEnvironment', 'allow_web_editing')) { $addNewRelease = new GridFieldAddNewButton('toolbar-header-right'); $addNewRelease->setButtonName('Add'); $environments->getConfig()->addComponent($addNewRelease); } $fields->addFieldToTab("Root.Main", $environments); }
/** * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeFieldFromTab('Root.Main', 'DataType'); $fields->removeByName('ContentSourceID'); $dataObjects = ClassInfo::subclassesFor('DataObject'); array_shift($dataObjects); natcasesort($dataObjects); $fields->addFieldToTab('Root.Main', new DropdownField('DataType', 'DataType', $dataObjects)); $importRules = $fields->dataFieldByName('ImportRules'); if ($importRules) { $importRules->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter'); $importRules->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $addNewButton = new GridFieldAddNewButton('after'); $addNewButton->setButtonName("Add Rule"); $importRules->getConfig()->addComponent($addNewButton); $fields->removeFieldFromTab('Root', 'ImportRules'); $fields->addFieldToTab('Root.Main', $importRules); } return $fields; }
public function getCMSFields() { $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', TextField::create("Title", $this->fieldLabel('Title')), TextField::create("URLSegment", $this->fieldLabel('URLSegment')), NumericField::create("Price", $this->fieldLabel('Price')), HTMLEditorField::create('Description', $this->fieldLabel('Price'))->setRows(20)->addExtraClass('stacked'), ToggleCompositeField::create('AdditionalData', 'Additional Data', array(NumericField::create("Quantity", $this->fieldLabel('Quantity')), TextField::create("SKU", $this->fieldLabel('SKU')), TextField::create("PackSize", $this->fieldLabel('PackSize')), TextField::create("Weight", $this->fieldLabel('Weight'))))->setHeadingLevel(4), ToggleCompositeField::create('Metadata', _t('CommerceAdmin.MetadataToggle', 'Metadata'), array($metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4), CheckboxField::create("Disabled", $this->fieldLabel('Disabled'))), $tabImages = new Tab('Images', SortableUploadField::create('Images', $this->fieldLabel('Images'), $this->Images())))); // Help text for MetaData on page content editor $metaFieldDesc->setRightTitle(_t('CommerceAdmin.MetaDescHelp', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help'); $metaFieldExtra->setRightTitle(_t('CommerceAdmin.MetaExtraHelp', "HTML tags for additional meta information. For example <meta name=\"customName\" content=\"your custom content here\" />"))->addExtraClass('help'); // Once product is saved, deal with more complex associations if ($this->ID) { // Deal with product features $add_button = new GridFieldAddNewInlineButton('toolbar-header-left'); $add_button->setTitle('Add Attribute'); $attributes_field = new GridField('Attributes', '', $this->Attributes(), GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction())->addComponent($add_button)->addComponent(new GridFieldOrderableRows('Sort'))); $fields->addFieldToTab('Root.Attributes', $attributes_field); // Deal with customisations $add_button = new GridFieldAddNewButton('toolbar-header-left'); $add_button->setButtonName('Add Customisation'); $custom_config = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), $add_button, new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldOrderableRows('Sort')); $custom_field = GridField::create('Customisations', '', $this->Customisations(), $custom_config); $fields->addFieldToTab('Root.Customisations', $custom_field); $related_field = GridField::create('RelatedProducts', "", $this->RelatedProducts(), GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab('Root.Related', $related_field); } $this->extend('updateCMSFields', $fields); return $fields; }