core/modules/system/src/Plugin/Block/SystemMenuBlock.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php index 21f4a08..8839f1e 100644 --- a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php @@ -81,9 +81,12 @@ public static function create(ContainerInterface $container, array $configuratio public function blockForm($form, FormStateInterface $form_state) { $config = $this->configuration; + $defaults = $this->defaultConfiguration(); $form['menu_levels'] = array( '#type' => 'details', '#title' => t('Limit menu levels displayed'), + // Open if not set to defaults. + '#open' => $defaults['level'] !== $config['level'] || $defaults['depth'] !== $config['depth'], ); $options = array( @@ -111,6 +114,7 @@ public function blockForm($form, FormStateInterface $form_state) { '#options' => $options, '#description' => $this->t('Blocks that start with the 1st level will always be visible. Blocks that start with the 2nd level or deeper will only be visible when the trail to the active menu passes through the block’s starting level.'), '#required' => TRUE, + '#parents' => ['settings', 'level'], ); $options = range(0, $this->menuTree->maxDepth()); @@ -123,6 +127,7 @@ public function blockForm($form, FormStateInterface $form_state) { '#options' => $options, '#description' => $this->t('Specify the maximum number of levels of the menu to display, beginning with the starting menu level selected above.'), '#required' => TRUE, + '#parents' => ['settings', 'depth'], ); return $form; @@ -131,14 +136,6 @@ public function blockForm($form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function blockSubmit($form, FormStateInterface $form_state) { - $this->configuration['level'] = $form_state->getValue(['menu_levels','level']); - $this->configuration['depth'] = $form_state->getValue(['menu_levels','depth']); - } - - /** - * {@inheritdoc} - */ public function build() { $menu_name = $this->getDerivativeId(); $parameters = $this->menuTree->getCurrentRouteMenuTreeParameters($menu_name);