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
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screen Shot 2022-10-19 at 11.03.52.png | 73.61 KB | lauriii |
Issue fork next_webform-3316148
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
Comment #3
hooroomooComment #4
hooroomooComment #5
hooroomooThis 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.
Comment #6
hooroomooComment #7
lauriiiI 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:

Comment #8
hooroomooComment #9
hooroomoo