12
12
namespace App \Site \Controllers \Admin ;
13
13
14
14
use App \Base \Exceptions \PermissionDeniedException ;
15
+ use App \Base \Traits \AdminFormTrait ;
15
16
use Degami \Basics \Exceptions \BasicException ;
16
17
use Exception ;
17
18
use Phpfastcache \Exceptions \PhpfastcacheSimpleCacheException ;
28
29
*/
29
30
class Blocks extends AdminManageModelsPage
30
31
{
32
+ use AdminFormTrait;
33
+
31
34
/**
32
35
* {@inheritdocs}
33
36
*
@@ -176,7 +179,8 @@ function ($el) {
176
179
]
177
180
);
178
181
if ($ type == 'new ' || $ block ->instance_class == Block::class) {
179
- $ form ->addField (
182
+ $ form
183
+ /*->addField(
180
184
'locale',
181
185
[
182
186
'type' => 'select',
@@ -185,7 +189,7 @@ function ($el) {
185
189
'options' => $languages,
186
190
'validate' => ['required'],
187
191
]
188
- )
192
+ )*/
189
193
->addField (
190
194
'content ' ,
191
195
[
@@ -196,6 +200,8 @@ function ($el) {
196
200
'rows ' => 20 ,
197
201
]
198
202
);
203
+
204
+ $ this ->addFrontendFormElements ($ form , $ form_state , ['website_id ' , 'locale ' ]);
199
205
}
200
206
$ form ->addField (
201
207
'rewrites ' ,
@@ -217,7 +223,7 @@ function ($el) {
217
223
);
218
224
219
225
220
- if ($ block != null && method_exists ($ block ->getRealInstance (), 'additionalConfigFieldset ' )) {
226
+ if ($ block != null && method_exists ($ block ->getRealInstance (), 'additionalConfigFieldset ' )) {
221
227
$ config_fields = call_user_func_array (
222
228
[$ block ->getRealInstance (), 'additionalConfigFieldset ' ],
223
229
[
@@ -282,6 +288,7 @@ public function formSubmitted(FAPI\Form $form, &$form_state)
282
288
$ block = $ this ->getObject ();
283
289
284
290
$ values = $ form ->values ();
291
+
285
292
switch ($ values ['action ' ]) {
286
293
case 'new ' :
287
294
$ block ->user_id = $ this ->getCurrentUser ()->id ;
@@ -292,7 +299,8 @@ public function formSubmitted(FAPI\Form $form, &$form_state)
292
299
case 'edit ' :
293
300
$ block ->region = $ values ['region ' ];
294
301
$ block ->title = $ values ['title ' ];
295
- $ block ->locale = $ values ['locale ' ];
302
+ $ block ->website_id = $ values ['frontend ' ]['website_id ' ];
303
+ $ block ->locale = $ values ['frontend ' ]['locale ' ];
296
304
$ block ->order = intval ($ values ['order ' ]);
297
305
298
306
if ($ values ['action ' ] == 'new ' || $ block ->getInstance () == Block::class) {
@@ -379,7 +387,7 @@ function ($block) {
379
387
'ID ' => $ block ->id ,
380
388
'Website ' => $ block ->getWebsiteId () == null ? $ this ->getUtils ()->translate ('All websites ' , $ this ->getCurrentLocale ()) : $ block ->getWebsite ()->domain ,
381
389
'Region ' => $ block ->region ,
382
- 'Locale ' => $ block ->isCodeBlock () ? $ block ->locale : $ this ->getUtils ()->translate ('All languages ' , $ this ->getCurrentLocale ()),
390
+ 'Locale ' => ! $ block ->isCodeBlock () ? $ block ->locale : $ this ->getUtils ()->translate ('All languages ' , $ this ->getCurrentLocale ()),
383
391
'Title ' => $ block ->title ,
384
392
'Where ' => (count ($ block ->getRewrites ())== 0 ) ? $ this ->getUtils ()->translate ('All Pages ' , $ this ->getCurrentLocale ()) : implode (
385
393
"<br> " ,
0 commit comments