Problem/Motivation

Saving the Entity Submenu Block results in:

TypeError: Drupal\Core\Form\FormStateDecoratorBase::setError(): Argument #1 ($element) must be of type array, null given, called in /web/core/modules/system/src/Plugin/Block/SystemMenuBlock.php on line 163 in Drupal\Core\Form\FormStateDecoratorBase->setError() (line 647 of core/lib/Drupal/Core/Form/FormStateDecoratorBase.php).

Also I see

Warning: Undefined array key "level" in Drupal\system\Plugin\Block\SystemMenuBlock->blockValidate() (Zeile 162 in /web/core/modules/system/src/Plugin/Block/SystemMenuBlock.php). =>

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anybody created an issue. See original summary.

grevil made their first commit to this issue’s fork.

grevil’s picture

Assigned: grevil » Unassigned
Status: Active » Needs review
Issue tags: -Needs tests

Fixed, please review!

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, RTBC as there are currently no other helpful validations:

  /**
   * {@inheritdoc}
   */
  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.'));
    }
  }

Hopefully this won't conflict with any submit values. I'm not even sure if it makes sense to extend SystemMenuBlock. I'll add a follow-up.

anybody’s picture

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.