diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index a2ca6e5..6e7e12d 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -24,6 +24,7 @@ block_admin_add: pattern: '/admin/structure/block/add/{plugin_id}/{theme}' defaults: _content: '\Drupal\block\Controller\BlockAddController::blockAddConfigureForm' + theme: null _title: 'Configure block' requirements: _permission: 'administer blocks' diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index e873888..7b55d62 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -228,6 +228,32 @@ public function form(array $form, array &$form_state) { '#description' => $this->t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'), ); + // Theme settings. + if ($theme = $entity->get('theme')) { + $form['theme'] = array( + '#type' => 'value', + '#value' => $entity->get('theme'), + ); + } + else { + $theme_options = array(); + foreach (list_themes() as $theme_name => $theme_info) { + if (!empty($theme_info->status)) { + $theme_options[$theme_name] = $theme_info->info['name']; + } + } + $theme = \Drupal::config('system.theme')->get('default'); + $form['theme'] = array( + '#type' => 'select', + '#options' => $theme_options, + '#title' => t('Theme'), + '#default_value' => $theme, + '#ajax' => array( + 'callback' => array($this, 'themeSwitch'), + 'wrapper' => 'edit-block-region-wrapper', + ), + ); + } // Region settings. $form['region'] = array( '#type' => 'select', @@ -235,12 +261,22 @@ public function form(array $form, array &$form_state) { '#description' => $this->t('Select the region where this block should be displayed.'), '#default_value' => $entity->get('region'), '#empty_value' => BLOCK_REGION_NONE, - '#options' => system_region_list($entity->get('theme'), REGIONS_VISIBLE), + '#options' => system_region_list($theme, REGIONS_VISIBLE), + '#prefix' => '