Skip to content

Commit d13c86e

Browse files
committed
fixed blocks admin page
1 parent 046516a commit d13c86e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

app/site/controllers/Admin/Blocks.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace App\Site\Controllers\Admin;
1313

1414
use App\Base\Exceptions\PermissionDeniedException;
15+
use App\Base\Traits\AdminFormTrait;
1516
use Degami\Basics\Exceptions\BasicException;
1617
use Exception;
1718
use Phpfastcache\Exceptions\PhpfastcacheSimpleCacheException;
@@ -28,6 +29,8 @@
2829
*/
2930
class Blocks extends AdminManageModelsPage
3031
{
32+
use AdminFormTrait;
33+
3134
/**
3235
* {@inheritdocs}
3336
*
@@ -176,7 +179,8 @@ function ($el) {
176179
]
177180
);
178181
if ($type == 'new' || $block->instance_class == Block::class) {
179-
$form->addField(
182+
$form
183+
/*->addField(
180184
'locale',
181185
[
182186
'type' => 'select',
@@ -185,7 +189,7 @@ function ($el) {
185189
'options' => $languages,
186190
'validate' => ['required'],
187191
]
188-
)
192+
)*/
189193
->addField(
190194
'content',
191195
[
@@ -196,6 +200,8 @@ function ($el) {
196200
'rows' => 20,
197201
]
198202
);
203+
204+
$this->addFrontendFormElements($form, $form_state, ['website_id', 'locale']);
199205
}
200206
$form->addField(
201207
'rewrites',
@@ -217,7 +223,7 @@ function ($el) {
217223
);
218224

219225

220-
if ($block != null && method_exists($block->getRealInstance(), 'additionalConfigFieldset')) {
226+
if ($block != null && method_exists($block->getRealInstance(), 'additionalConfigFieldset')) {
221227
$config_fields = call_user_func_array(
222228
[$block->getRealInstance(), 'additionalConfigFieldset'],
223229
[
@@ -282,6 +288,7 @@ public function formSubmitted(FAPI\Form $form, &$form_state)
282288
$block = $this->getObject();
283289

284290
$values = $form->values();
291+
285292
switch ($values['action']) {
286293
case 'new':
287294
$block->user_id = $this->getCurrentUser()->id;
@@ -292,7 +299,8 @@ public function formSubmitted(FAPI\Form $form, &$form_state)
292299
case 'edit':
293300
$block->region = $values['region'];
294301
$block->title = $values['title'];
295-
$block->locale = $values['locale'];
302+
$block->website_id = $values['frontend']['website_id'];
303+
$block->locale = $values['frontend']['locale'];
296304
$block->order = intval($values['order']);
297305

298306
if ($values['action'] == 'new' || $block->getInstance() == Block::class) {
@@ -379,7 +387,7 @@ function ($block) {
379387
'ID' => $block->id,
380388
'Website' => $block->getWebsiteId() == null ? $this->getUtils()->translate('All websites', $this->getCurrentLocale()) : $block->getWebsite()->domain,
381389
'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()),
383391
'Title' => $block->title,
384392
'Where' => (count($block->getRewrites())== 0) ? $this->getUtils()->translate('All Pages', $this->getCurrentLocale()) : implode(
385393
"<br>",

0 commit comments

Comments
 (0)