webform element to display external html data

Created on 1 August 2023, 11 months ago
Updated 3 August 2023, 11 months ago

I would like to have a new webform element that displays read-only html in a webform and in its websubmission.

Requirements:
- You would extend the classes when you want to build a specific html-fragment: the html generation would be in the derived class
- We need some mechanism to call a service or get data once, and then be able to use that data in the html generation.

My use case:
- I need data from an external (slow) service to be (read-only) on a webform and in its websubmission. I can massage the data into html format, but I only want to call the service once per user/per webform.
- Once the data is saved in a websubmission the service should not be called anymore, the html at the time of saving is to be saved as text.

I tried a couple of things:
- I made a copy of the WebformComputedTwig element and replaced the twig parts. Problem then is that the "computeValue()" is called numerous times when you fill in the webform. Caching is also not easy as the callbacks are static functions.
- I used hook_form_alter() to add html data to the webform, but with hook_form_alter() the data is shown on the webform but doesn't (of course) appear in the websubmission.

Regards,
Sven

πŸ’¬ Support request
Status

Closed: outdated

Version

6.2

Component

Code

Created by

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

Comments & Activities

Production build 0.69.0 2024