diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index f36d8c1..7b55d62 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -248,6 +248,10 @@ public function form(array $form, array &$form_state) { '#options' => $theme_options, '#title' => t('Theme'), '#default_value' => $theme, + '#ajax' => array( + 'callback' => array($this, 'themeSwitch'), + 'wrapper' => 'edit-block-region-wrapper', + ), ); } // Region settings. @@ -258,11 +262,21 @@ public function form(array $form, array &$form_state) { '#default_value' => $entity->get('region'), '#empty_value' => BLOCK_REGION_NONE, '#options' => system_region_list($theme, REGIONS_VISIBLE), + '#prefix' => '
', + '#suffix' => '
', ); return $form; } /** + * Handles switching the available regions based on the selected theme. + */ + public function themeSwitch($form, &$form_state) { + $form['region']['#options'] = system_region_list($form_state['values']['theme'], REGIONS_VISIBLE); + return $form['region']; + } + + /** * {@inheritdoc} */ protected function actions(array $form, array &$form_state) {