Error when updating a webform element programatically (specifically composite elements)

Created on 16 April 2025, 17 days ago

Problem/Motivation

When attempting to update a webform element programatically that is either a composite element or contains a composite element, we're receiving the following error "Object support when dumping a YAML file has been disabled."

Steps to reproduce

- Create a webform
- Add a composite element to it and save
- Create a Drush script or an update hook
- Load the webform using its ID.
- Get the element using getElement and its machine name
- Change one of the elements properties
- Call setElementProperties using its key and the modified element
- Error is produced

Proposed resolution

The error seems to stem from composite elements where the TranslatableMarkup class has been used as part of its properties definition in the getCompositeElements method. When attempting to dump the array in the WebformYaml class, objects are not allowed and therefore an error is produced.

Not sure what the resolution is aside from not using TranslatableMarkup in the getCompositeElements method or recursively converting them to be strings prior to dumping?

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

6.3

Component

Code

Created by

🇦🇺Australia mortim07

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

Comments & Activities

Production build 0.71.5 2024