From 30bdaca99044521db78e03b0f0c69bd65aea9b73 Mon Sep 17 00:00:00 2001 From: James Cocker Date: Sat, 6 Mar 2021 13:34:15 +0000 Subject: [PATCH 1/2] Add ability to specify location for Elemental Area field via custom "insert before" --- src/Extensions/ElementalAreasExtension.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Extensions/ElementalAreasExtension.php b/src/Extensions/ElementalAreasExtension.php index 73853718..81e5deea 100644 --- a/src/Extensions/ElementalAreasExtension.php +++ b/src/Extensions/ElementalAreasExtension.php @@ -202,7 +202,11 @@ public function updateCMSFields(FieldList $fields) $editor = ElementalAreaField::create($eaRelationship, $area, $this->getElementalTypes()); - if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) { + $insertBefore = Config::inst()->get(get_class($this->owner), 'insert_before_field_name'); + + if ($insertBefore && $fields->dataFieldByName($insertBefore)) { + $fields->addFieldToTab('Root.Main', $editor, $insertBefore); + } else if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) { $fields->addFieldToTab('Root.Main', $editor, 'Metadata'); } else { $fields->addFieldToTab('Root.Main', $editor); From 27e1b0c6b012266e64ea309ab5bacb790ad1520d Mon Sep 17 00:00:00 2001 From: James Cocker Date: Sun, 7 Mar 2021 20:53:47 +0000 Subject: [PATCH 2/2] ElementalArea: Changed to use `insertBefore` instead of `addFieldToTab` --- src/Extensions/ElementalAreasExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/ElementalAreasExtension.php b/src/Extensions/ElementalAreasExtension.php index 81e5deea..c3c889e6 100644 --- a/src/Extensions/ElementalAreasExtension.php +++ b/src/Extensions/ElementalAreasExtension.php @@ -205,7 +205,7 @@ public function updateCMSFields(FieldList $fields) $insertBefore = Config::inst()->get(get_class($this->owner), 'insert_before_field_name'); if ($insertBefore && $fields->dataFieldByName($insertBefore)) { - $fields->addFieldToTab('Root.Main', $editor, $insertBefore); + $fields->insertBefore($insertBefore, $editor); } else if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) { $fields->addFieldToTab('Root.Main', $editor, 'Metadata'); } else {