Problem/Motivation

In a multistep webform with almost one field date, when webform is submitted throws following error:

Error message
Notice: Undefined index: object in Drupal\webform\Plugin\WebformElement\DateBase::validateDate() (line 358 of modules/contrib/webform/src/Plugin/WebformElement/DateBase.php).

Proposed resolution

I have checked if $value has a 'object' index and if else, I check if it is an array, I pass the correct $value argument to 'date_create_from_format' function.

I have attached a patch to fix this.

Comments

Daniel Ortega created an issue. See original summary.

daniel ortega’s picture

Status: Needs review » Needs work
daniel ortega’s picture

jrockowitz’s picture

Status: Needs work » Postponed (maintainer needs more info)
StatusFileSize
new3.63 KB

@Daniel Ortega I can't replicate this issue using the attached webform which contains 2 pages with date and datelist elements.

igalafate’s picture

StatusFileSize
new3.66 KB

@jrockowitz I have the same issue and, looking at your config, the thing is when I export the form I get the "'#multiple': 0\n" config added to my date field even if I do not change anything from the UI. I am using the 8.x-5.0-rc3 version of Webform. Is it possible you are using the dev one or maybe you have patched it?

Please, see attached your version after I have save the "date_1" field. By the way, thank you for your attaching your config file, it was the key to see the issue.

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Needs work
StatusFileSize
new3.38 KB

Wow, the '#multiple': 0 is triggering this error when I page next and previous on the attached webform.

What is even more remarkable is '#multiple': 2 is fine.

The 0 is probably causing some unexpected issue via an empty() call.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new589 bytes

So '#multiple': 0 is not really supported via the UI and was probably set via edit the YAML source. Still we should try to account this value.

jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

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