Datelist element can not save 1970/01/01 value when setting Required for Enable preview page

Created on 1 October 2023, about 1 year ago
Updated 5 October 2023, about 1 year ago

Problem/Motivation

Datelist element cannot save 1970/01/01 value when Enable preview settings is Required

Steps to reproduce

  1. Create new webform
  2. Add Date list element (ex: birthday) and setting date part only Years Months and Dates, other settings keep default
  3. Form preview settings - Enable preview settings - select Required
  4. Access view webform and input value Year: 1970 - Month: Jan - Date: 1
  5. Click Preview then Confirm
  6. Check submission results. Value of datelist field is empty

Proposed resolution

This issue related to strtotime function is used in Drupal\webform\Plugin\WebformElement\DateBase::parseInputFormat()
With value "1970-01-01T00:00:00+0000" it returned 0 so it set NULL for default value of element.

Suggest modify code by setting NULL in case strtotime return FALSE.

πŸ› Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

πŸ‡»πŸ‡³Vietnam ypx

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.71.5 2024