Browse code

Add used fieldGroups to template after parent compile so it doesn't get overridden

Benjamin Roth authored on21/02/2020 12:51:02
Showing2 changed files
... ...
@@ -55,6 +55,7 @@ class ModulePersonalData extends \Contao\ModulePersonalData
55 55
     $this->originalDca = $GLOBALS['TL_DCA']['tl_member'];
56 56
 
57 57
     $arrEditable = [];
58
+    $arrFieldgroups = [];
58 59
     foreach ($this->editable as $key=>$fielddata)
59 60
     {
60 61
       // Split formilicious editable data in single vars
... ...
@@ -65,6 +66,12 @@ class ModulePersonalData extends \Contao\ModulePersonalData
65 66
         continue;
66 67
       }
67 68
 
69
+      $fieldGroupTmp = $fieldGroup ?: $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['feGroup'];
70
+      if (!\in_array($fieldGroupTmp,$arrFieldgroups))
71
+      {
72
+        $arrFieldgroups[] = $fieldGroupTmp;
73
+      }
74
+
68 75
       $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_class'] = $fieldClass;
69 76
       $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_width'] = $fieldWidth;
70 77
       $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_clear'] = $fieldClr;
... ...
@@ -82,5 +89,6 @@ class ModulePersonalData extends \Contao\ModulePersonalData
82 89
 
83 90
     parent::compile();
84 91
 
92
+    $this->Template->fieldGroups = $arrFieldgroups;
85 93
   }
86 94
 }
... ...
@@ -66,9 +66,10 @@ class ModuleRegistration extends \Contao\ModuleRegistration
66 66
         continue;
67 67
       }
68 68
 
69
-      if (!\in_array($fieldGroup,$arrFieldgroups))
69
+      $fieldGroupTmp = $fieldGroup ?: $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['feGroup'];
70
+      if (!\in_array($fieldGroupTmp,$arrFieldgroups))
70 71
       {
71
-        $arrFieldgroups[] = $fieldGroup;
72
+        $arrFieldgroups[] = $fieldGroupTmp;
72 73
       }
73 74
 
74 75
       $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_class'] = $fieldClass;
... ...
@@ -92,9 +93,8 @@ class ModuleRegistration extends \Contao\ModuleRegistration
92 93
       \Input::setPost('username',\Input::post('email'));
93 94
     }
94 95
 
95
-    $this->Template->fieldGroups = $arrFieldgroups;
96
-
97 96
     parent::compile();
98 97
 
98
+    $this->Template->fieldGroups = $arrFieldgroups;
99 99
   }
100 100
 }