Problem/Motivation

Steps to reproduce

  1. Install D10 base with 6.2.0-beta6 webform
  2. Create a webform with multi page
  3. Add Date field on Page 1
  4. Add another date field on Page 2
  5. Use the Date value of page 1 as the minimum or maximum value Date field on page 2 ([webform_submission:values:test_date])
  6. This throws "Unable to render elements, please view the below message(s) and the error log.
    The timestamp must be numeric." error.

*** Replace '-1 day' with '[webform_submission:values:test_date]' to replicate the error in yml file ***

Works fine on D9 and the installed Webform version is 6.1.4.

Comments

Anil Thapa created an issue. See original summary.

anil thapa’s picture

Issue summary: View changes
anil thapa’s picture

Issue summary: View changes
kasliwal_harshit’s picture

StatusFileSize
new403.91 KB
new95.12 KB

Tried to reproduce the issue getting the same error (The timestamp must be numeric.) while working with D10 and webform 6.2.0-beta6 .
However when i tried to reproduce the same in D9 and with webform 6.1.4 though we are able to save the webform fields and condition without any error . however we are not getting the desired result .

Follow the same steps as mentioned in the issue with D9 and webform 6.1.4 , Set the page2 date field min value to date1 field value using (([webform_submission:values:date1_field_name]) . Now when we try to submit the response , the date validation for date2 is checking min value against the submission date of webform(today) instead of the date1 field value which is not the ideal behaviour.

Adding the screenshot for the same.

jrockowitz’s picture

jrockowitz’s picture

So the below YAML source when pasted into a D10 6.2.x webform trigger the error

page_01:
  '#type': wizard_page
  '#title': page_01
  date_01:
    '#type': date
    '#title': date_01
page_02:
  '#type': wizard_page
  '#title': page_02
  date_02:
    '#type': date
    '#title': date_02
    '#date_date_min': '[webform_submission:values:date_01]'
jrockowitz’s picture

StatusFileSize
new1.24 KB

I was not able to track down the root cause of the regression but the attached patch is reasonable and safe fix to immediate issue and is unlikely to cause additional regressions.

jrockowitz’s picture

Status: Active » Needs review
kasliwal_harshit’s picture

StatusFileSize
new471.96 KB

@jrockowitz i tried to applied the patch(#7) , after applying the patch although we are successfully able to save webform with the conditions on the date field , however we are still getting same error now upon submission of the webform. Attaching the screenshot for reference .

jrockowitz’s picture

Status: Needs review » Needs work
jrockowitz’s picture

The error is originating from \Drupal\Component\Datetime\DateTimePlus::createFromTimestamp

jrockowitz’s picture

Version: 6.2.0-beta6 » 6.1.x-dev
StatusFileSize
new1020 bytes

A slightly better approach where all invalid element date properties will unset. This approach can be used to prevent other date-related regressions.

This patch should also be applied to 6.1.x

jrockowitz’s picture

Status: Needs work » Needs review
liam morland’s picture

Version: 6.1.x-dev » 6.2.x-dev

The patch applies to 6.2.x but not 6.1.x.

liam morland’s picture

The patch will stop the "timestamp must be numeric" errors. But is this field supposed to be able to support tokens? Should it set an error message when it encounters an invalid value in one of the four properties that it checks?

jrockowitz’s picture

The tokens are replaced via parent::prepare($element, $webform_submission).

If the tokens are NOT replaced, they are invalid, so they should be removed.

liam morland’s picture

OK, so you're saying that any valid tokens will have already been replaced? That makes sense. In that case, this patch makes sense to me.

liam morland’s picture

Status: Needs review » Fixed
liam morland’s picture

Title: The timestamp must be numeric. » The timestamp must be numeric

Status: Fixed » Closed (fixed)

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

rohit tiwari’s picture

I am getting the same issue still on same scenario as mentioned in the issue summary.

My setup is:
Drupal: 9.5.8
Webform: 6.2.3

Error: InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of /mnt/www/html/trimedcmsej6ddn8fnr/docroot/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

liam morland’s picture

What property is causing the problem? Maybe something else needs to be added to $date_properties.

rohit tiwari’s picture

This is the YML causing issue:

published_dates:
    '#type': flexbox
    publish_date:
      '#type': datetime
      '#title': 'Publish Date'
      '#date_date_min': TODAY
      '#date_date_format': ''
      '#date_time_format': ''
      '#date_time_step': '60'
      '#required': true
    unpublish_date:
      '#type': datetime
      '#title': 'Unpublish Date (if any)'
      '#date_date_min': '[webform_submission:values:publish_date]'
      '#date_date_format': ''
      '#date_time_format': ''
      '#date_time_step': '60'

Specifically this token: [webform_submission:values:publish_date]

jrochate’s picture

I'm also having this problem:

webform 6.2.x
drupal 10.3

    data_evento_inicio:
      '#type': datetime
      '#title': 'Data do Evento'
      '#title_display': inline
      '#required': true
      '#format': simple_datetime_alt
      '#date_year_range': ''
    data_evento_fim:
      '#type': datetime
      '#title': Fim
      '#title_display': inline
      '#required': true
      '#date_min': '[webform_submission:values:data_evento_inicio:raw]'
      '#format': simple_datetime_alt
      '#date_year_range': ''

I think the best is to use raw as should result in an UNIXTIMESTAMP.

But I'm getting the error:

Unable to render elements, please view the below message(s) and the error log.

The timestamp must be numeric.

Is it impossible to reference previous submissions fields on this validation rule?

Can't find out the limitation. TIA