| @@ 33-57 (lines=25) @@ | ||
| 30 | /** |
|
| 31 | * @return FieldList |
|
| 32 | */ |
|
| 33 | public function getCMSFields() |
|
| 34 | { |
|
| 35 | $fields = parent::getCMSFields(); |
|
| 36 | ||
| 37 | $fields->removeByName(array( |
|
| 38 | 'SortOrder', |
|
| 39 | 'Panels', |
|
| 40 | )); |
|
| 41 | ||
| 42 | $config = GridFieldConfig_RecordEditor::create(); |
|
| 43 | if (class_exists('GridFieldOrderableRows')) { |
|
| 44 | $config->addComponent(new GridFieldOrderableRows()); |
|
| 45 | } |
|
| 46 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
|
| 47 | $config->removeComponentsByType('GridFieldDeleteAction'); |
|
| 48 | $config->addComponent(new GridFieldDeleteAction(false)); |
|
| 49 | ||
| 50 | if ($this->ID) { |
|
| 51 | $fields->addFieldsToTab('Root.Panels', array( |
|
| 52 | GridField::create('Panels', 'Accordion Panels', $this->Panels()->sort('Sort'), $config), |
|
| 53 | )); |
|
| 54 | } |
|
| 55 | ||
| 56 | return $fields; |
|
| 57 | } |
|
| 58 | } |
|
| @@ 31-51 (lines=21) @@ | ||
| 28 | /** |
|
| 29 | * @return FieldList |
|
| 30 | */ |
|
| 31 | public function getCMSFields() |
|
| 32 | { |
|
| 33 | $fields = parent::getCMSFields(); |
|
| 34 | ||
| 35 | if ($this->ID) { |
|
| 36 | // Sections |
|
| 37 | $config = GridFieldConfig_RecordEditor::create(); |
|
| 38 | if (class_exists('GridFieldSortableRows')) { |
|
| 39 | $config->addComponent(new GridFieldSortableRows('SortOrder')); |
|
| 40 | } |
|
| 41 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
|
| 42 | $config->removeComponentsByType('GridFieldDeleteAction'); |
|
| 43 | $config->addComponent(new GridFieldDeleteAction(false)); |
|
| 44 | $sectionsField = GridField::create('Sections', 'Sections', $this->Sections()->sort('SortOrder'), $config); |
|
| 45 | $fields->addFieldsToTab('Root.Sections', array( |
|
| 46 | $sectionsField, |
|
| 47 | )); |
|
| 48 | } |
|
| 49 | ||
| 50 | return $fields; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return mixed |
|