Source of file SectionGalleryBlock.php
Size: 1,678 Bytes - Last Modified: 2021-12-23T10:11:59+00:00
/var/www/docs.ssmods.com/process/src/code/Blocks/SectionGalleryBlock.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | <?php class SectionGalleryBlock extends Section { public static $db = array(); public static $has_many = array( 'GalleryImages' => 'ImageResource' ); public static $has_one = array(); public function getCMSFields() { $fields = parent::getCMSFields(); $dataColumns = new GridFieldDataColumns(); $dataColumns->setDisplayFields( array( 'ID' => 'ID', 'ClassName' => 'Class Name', ) ); //---------------------- Main ----------------------// $saveWarning = LiteralField::create("Warning", "<p class='cms-warning-label'>You must first save the Gallery block before adding gallery images</p>"); $images = GridField::create('GalleryImages', 'Gallery Images', $this->GalleryImages(), GridFieldConfig::create()->addComponents( $dataColumns, new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldDetailForm(), new GridFieldEditButton(), new GridFieldDeleteAction('unlinkrelation'), new GridFieldDeleteAction(), new GridFieldTitleHeader(), new GridFieldAddExistingAutocompleter('before', array('Title')) ) ); if (!$this->ID) { $images->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $fields->addFieldToTab('Root.Main', $saveWarning); } $fields->addFieldToTab('Root.Main', $images); $this->removeEmptyTabs($fields); return $fields; } } |