Problem/Motivation

Custom Composite element allow users to use the Date elements inside of it, but it takes a lot of the options/properties you have in the "standalone" Date element for the sake of UI (I believe).

To allow users to get these options/properties set on the Custom Composite child elements we have the Custom Properties field. All good.

The issue is that when building a multi-page (or one-page preview enabled) webform, with a Date element inside a Custom Composite and setting it to have a datepicker and a different date format other than "YYYY-MM-DD", the data gets lost as it moves between pages or pass through the preview.

This doesn't happen for one-page webforms the are directly submitted to the database.
This doesn't happen for Date elements that are outside Custom Composite elements.

I'm attaching 2 different YAML files for the test webforms I've created.
Use it and try to enable/disable the preview to see the difference on the behavior.

Proposed resolution

I don't really have a solution for this because I couldn't really figure out where the data was getting lost.

I was able to see the data in the WebformSubmission object right after going to the next page, and I notice it was set to the standard format (YYYY-MM-DD).

My guess is that whenever moving the data, some validation (or other step in the process) tries to match the YYYY-MM-DD format to the custom date format I've set (d/m/Y) and when it doesn't match, it loses the data.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dscl created an issue. See original summary.

jrockowitz’s picture

The attached webform replicates the issue.

jrockowitz’s picture

Status: Active » Needs review
FileSize
1.48 KB
dscl’s picture

Status: Needs review » Reviewed & tested by the community

Wow, that was quick!
Thanks a lot for your effort on this.

I've reviewed it and test, works perfectly.
And also allows me to better understand the flow of data.

Cheers!

  • jrockowitz committed 143a415 on 8.x-5.x
    Issue #2973063 by jrockowitz, dscl: Date elements w/ data format on...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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