Undefined array key "" in Drupal\webform\WebformSubmissionForm->form()

Created on 31 August 2022, almost 2 years ago
Updated 30 May 2023, about 1 year ago

Problem/Motivation

When saving a complex webform, we're getting the following warning:

Warning: Undefined array key "" in Drupal\webform\WebformSubmissionForm->form() (Zeile 722 in /web/modules/contrib/webform/src/WebformSubmissionForm.php)

The affected line is:

        $form['#attributes']['data-webform-wizard-current-page'] = ($track_pages[$current_page] + 1);

in

    // Track current page name or index by setting the
    // "data-webform-wizard-page"
    // attribute which is used Drupal.behaviors.webformWizardTrackPage.
    //
    // The data parameter is append to the URL after the form has
    // been submitted.
    //
    // @see js/webform.wizard.track.js
    $track = $this->getWebform()->getSetting('wizard_track');
    if ($track && $this->getRequest()->isMethod('POST')) {
      $current_page = $this->getCurrentPage($form, $form_state);
      if ($track === 'index') {
        $pages = $this->getWebform()->getPages($this->operation);
        $track_pages = array_flip(array_keys($pages));
        $form['#attributes']['data-webform-wizard-current-page'] = ($track_pages[$current_page] + 1);
      }
      else {
        $form['#attributes']['data-webform-wizard-current-page'] = $current_page;
      }
    }

$current_page is an empty string:
$current_page string (0) ""

$track_pages is an empty array:
$track_pages array (0)

So I guess this needs a further check.

Workaround:
Set "Track wizard progress in the URL by" to "None".

Steps to reproduce

This is the wizard configuration where this happens:

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

6.1

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024