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