@@ -76,7 +76,15 @@ public function createWidgetContao(CreateWidgetEvent $event)
76
76
if (Input::get ('act ' ) == 'editAll ' ) {
77
77
$ fieldName = \preg_replace ('/(.*)_[0-9a-zA-Z]+$/ ' , '$1 ' , $ fieldName );
78
78
}
79
- $ dcDriver ->field = $ fieldName ;
79
+
80
+ // A MCW in a MCW has a path.
81
+ $ path = \preg_split ('/[\[|\]]/i ' , $ fieldName );
82
+ $ path = array_filter ($ path , 'strlen ' );
83
+
84
+ // The first should be the default MCW on the root level.
85
+ if (count ($ path ) > 1 ) {
86
+ $ fieldName = $ path [0 ];
87
+ }
80
88
81
89
// The field does not exist
82
90
if (!isset ($ GLOBALS ['TL_DCA ' ][$ dcDriver ->table ]['fields ' ][$ fieldName ])) {
@@ -93,29 +101,62 @@ public function createWidgetContao(CreateWidgetEvent $event)
93
101
throw new BadRequestHttpException ('Bad request ' );
94
102
}
95
103
96
- $ inputType = $ GLOBALS ['TL_DCA ' ][$ dcDriver ->table ]['fields ' ][$ fieldName ]['inputType ' ];
97
-
98
- /** @var string $widgetClassName */
99
- $ widgetClassName = $ GLOBALS ['BE_FFL ' ][$ inputType ];
100
-
101
- /** @var MultiColumnWizard $widget */
102
- /** @var MultiColumnWizard $widgetClassName */
103
- $ widget = new $ widgetClassName (
104
- $ widgetClassName ::getAttributesFromDca (
105
- $ GLOBALS ['TL_DCA ' ][$ dcDriver ->table ]['fields ' ][$ fieldName ],
106
- $ dcDriver ->inputName ,
107
- '' ,
108
- $ fieldName ,
109
- $ dcDriver ->table ,
110
- $ dcDriver
111
- )
104
+ // MCW in MCW will generate a path, all else will be a array with one element.
105
+ $ this ->loadDcaSettingInDepth (
106
+ $ dcDriver ,
107
+ $ GLOBALS ['TL_DCA ' ][$ dcDriver ->table ]['fields ' ],
108
+ $ path ,
109
+ $ event
112
110
);
111
+ }
113
112
114
- // Set some more information.
115
- $ widget ->currentRecord = $ dcDriver ->id ;
116
- $ widget ->activeRecord = $ dcDriver ->activeRecord ;
113
+ /**
114
+ * @return void
115
+ */
116
+ private function loadDcaSettingInDepth ($ dcDriver , $ dca , $ path , $ event )
117
+ {
118
+ $ currentElement = $ path [0 ];
119
+
120
+ if (count ($ path ) > 1 ) {
121
+ if (array_key_exists ($ currentElement , $ dca ) && $ dca [$ currentElement ]['inputType ' ] == 'multiColumnWizard ' ) {
122
+ $ this ->loadDcaSettingInDepth
123
+ (
124
+ $ dcDriver ,
125
+ $ dca [$ currentElement ]['eval ' ]['columnFields ' ],
126
+ array_slice ($ path , 2 ),
127
+ $ event
128
+ );
129
+ return ;
130
+ } else {
131
+ // The path isn't a MCW element so someting is broken?
132
+ throw new BadRequestHttpException ('Bad request -- Got a MCW path, but can \'t be found ' );
133
+ }
134
+ } else {
135
+ $ mcwDca = $ dca [$ currentElement ];
136
+ $ inputType = $ mcwDca ['inputType ' ];
137
+
138
+ /** @var string $widgetClassName */
139
+ $ widgetClassName = $ GLOBALS ['BE_FFL ' ][$ inputType ];
140
+
141
+ /** @var MultiColumnWizard $widget */
142
+ /** @var MultiColumnWizard $widgetClassName */
143
+ $ widget = new $ widgetClassName (
144
+ $ widgetClassName ::getAttributesFromDca (
145
+ $ mcwDca ,
146
+ $ currentElement ,
147
+ '' ,
148
+ $ fieldName ,
149
+ $ dcDriver ->table ,
150
+ $ dcDriver
151
+ )
152
+ );
117
153
118
- $ event ->setWidget ($ widget );
154
+ // Set some more information.
155
+ $ widget ->currentRecord = $ dcDriver ->id ;
156
+ $ widget ->activeRecord = $ dcDriver ->activeRecord ;
157
+
158
+ $ event ->setWidget ($ widget );
159
+ }
119
160
}
120
161
121
162
/**
@@ -142,7 +183,7 @@ public function createWidgetDcGeneral(CreateWidgetEvent $event)
142
183
}
143
184
144
185
// Trigger the dcg to generate the data.
145
- $ env = $ dcGeneral ->getEnvironment ();
186
+ $ env = $ dcGeneral ->getEnvironment ();
146
187
$ model = $ dcGeneral ->getModel () ?: $ dcGeneral
147
188
->getEnvironment ()
148
189
->getDataProvider ()
0 commit comments