Source of file GridFieldConfig_FeatureGroup.php
Size: 2,604 Bytes - Last Modified: 2021-12-24T06:35:12+00:00
/var/www/docs.ssmods.com/process/src/src/GridField/GridFieldConfig_FeatureGroup.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php namespace SilverShop\Comparison\GridField; use SilverShop\Comparison\Model\Feature; use SilverStripe\Core\Config\Config; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\GridField\GridFieldButtonRow; use SilverStripe\Forms\GridField\GridFieldConfig; use SilverStripe\Forms\GridField\GridFieldDeleteAction; use SilverStripe\Forms\GridField\GridFieldFooter; use SilverStripe\Forms\GridField\GridFieldToolbarHeader; use SilverStripe\Forms\TextField; use Symbiote\GridFieldExtensions\GridFieldAddNewInlineButton; use Symbiote\GridFieldExtensions\GridFieldEditableColumns; use Symbiote\GridFieldExtensions\GridFieldOrderableRows; use Symbiote\GridFieldExtensions\GridFieldTitleHeader; /** * Allows editing of records contained within the GridField, instead of only allowing the ability to view records in * the GridField. */ class GridFieldConfig_FeatureGroup extends GridFieldConfig { /** * * @param int $itemsPerPage - How many items per page should show up * @param bool $showPagination Whether the `Previous` and `Next` buttons should display or not, leave as null to use default * @param bool $showAdd Whether the `Add` button should display or not, leave as null to use default */ public function __construct($itemsPerPage = null, $showPagination = null, $showAdd = null) { parent::__construct(); $displayFields = [ 'Title' => [ 'title' => 'Title', 'field' => TextField::class, ], 'Unit' => [ 'title' => 'Unit', 'field' => TextField::class, ], 'ValueType' => function($record, $column, $grid) { return DropdownField::create($column,"Value Type", singleton(Feature::class)->dbObject('ValueType')->enumValues()); } ]; $this->addComponent($editableColumns = new GridFieldEditableColumns()); $editableColumns->setDisplayFields($displayFields); $sortByGroup = Config::inst()->get(Feature::class, 'sort_features_by_group'); if( $sortByGroup ) { $this->addComponent(new GridFieldOrderableRows()); } $this->addComponent(new GridFieldButtonRow('before')); $this->addComponent(new GridFieldAddNewInlineButton('buttons-before-left')); $this->addComponent(new GridFieldToolbarHeader()); $this->addComponent(new GridFieldTitleHeader()); $this->addComponent(new GridFieldFooter()); $this->addComponent(new GridFieldDeleteAction()); $this->extend('updateConfig'); } } |