Problem/Motivation

Some elements such as contact composite element and basic address composite element have default values that are { content: "[]", headers: {X-Sub-Content-Type: null}} out of the box.

Update: After testing setting a default value for a composite element, I saw that the default value doesn't get set for composite elements because the data is shaped differently so I added functionality for that as well.

Steps to reproduce

1. Add a contact composite element or basic address composite element to your webform.
2. Look into the element and object and see that #default_value: { content: "[]", headers: {X-Sub-Content-Type: null}}

The webform data then gets set to those values on page load.

Proposed resolution

Add a check in getInitialData() function in utils.tsx to not set those values.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#7 Screen Shot 2022-10-19 at 11.03.52.png73.61 KBlauriii
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hooroomoo created an issue. See original summary.

hooroomoo’s picture

Issue summary: View changes
hooroomoo’s picture

Issue summary: View changes
hooroomoo’s picture

This PR checks if the element['#default_content'] does not include a headers key and also adds functionality for setting default values for text inputs in a composite element.

hooroomoo’s picture

Issue summary: View changes
lauriii’s picture

Issue summary: View changes
StatusFileSize
new73.61 KB

I tried testing this with the basic address composite element and I'm getting this error both before and after this change. It seems to have something to do with setting the default value:

hooroomoo’s picture

Status: Active » Needs review
hooroomoo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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