function SystemMenuBlock::blockValidate

Overrides BlockPluginTrait::blockValidate

File

core/modules/system/src/Plugin/Block/SystemMenuBlock.php, line 156

Class

SystemMenuBlock
Provides a generic Menu block.

Namespace

Drupal\system\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) : void {
  $values = $form_state->getValues();
  if (!empty($values['add_active_trail_class'])) {
    return;
  }
  if ((int) $values['level'] !== 1 || empty($values['expand_all_items']) && (int) $values['depth'] !== 1) {
    $form_state->setError($form['menu_levels']['add_active_trail_class'], $this->t('"Add a CSS class to ancestors of the current page" is required if the menu if the initial is 1, or if menu items are not all expanded and the number of levels display is more than 1.'));
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.