JSON:API FieldEnhancer ignores date field attributes

Created on 3 May 2023, over 1 year ago

Problem/Motivation

We've been using this to handle Webform requests from our Next.js site, but have just hit a snag when trying to add a new Date field. The Date field itself is usable, but does not correctly limit the days allowed from Tuesday to Saturday. This is because the #date_days attribute, which is necessary to convey this information, is absent from the JSON:API response, probably because it's an array of integers representing the days of the week. I suspect that the default fallback case in WebformElementsEnhancer::normalizeAttributes is stripping it out.

Steps to reproduce

  1. Install this module
  2. Create a new webform with a Date field
  3. Limit the range of days allowed in the field
  4. View the webform through JSON:API, and the #date_days attribute should be present, but is absent

Proposed resolution

Check why the default case for array attributes is to be ignored, and mitigate or remove it. I don't think there needs to be a special case for Date-specific attributes, but we should work out why arrays are filtered out in the first place.

Remaining tasks

  1. Investigate module and patch to correct behaviour

User interface changes

None.

API changes

None; JSON:API response should still be usable.

Data model changes

Probably some change at the JSON:API end related to how array attributes are represented.

🐛 Bug report
Status

Active

Component

Code

Created by

🇦🇺Australia geoffreyr

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

Comments & Activities

Production build 0.71.5 2024