Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Webform widget handler

Security covered Under active development 2 sites

Part of the Webform ecosystem · 225 projects

This module allows you to customize the editor's experience when embedding webforms into other content. It replaces complex configuration fields, like YAML, with more user-friendly options, such as select lists, to make it easier for editors to manage webform settings and variants.

Allows for webform handlers to alter the field widget editors see
when a webform is embedded into an entity with a field.

For example instead of presenting a YAML field to provide
default data for the webform you can replace that YAML
with a select field that has webform variants as options
so the editor can see a summary of what the variant does.

Setup

First a webform custom handler is needed.
This handler must implement a formElementFieldWidget method.
Add an instance of that handler to a webform. There is an example
in the modules folder of this project that shows a select form field
to choose between two variants.

Add a webform field to you entity and configure the field
widget that this module provides: "Select list with handler control".
It is recommended to uncheck "Enable default submission data (YAML)"
hiding the textarea to write YAML.

Add or edit an entity that has the webform field configured,
select a webform that has the custom handler enabled and
the custom handler will be called to alter the widget.

Example module

The example module shipped along with the main module
showcases how to use with a contact webform similar to
the one from the webform module adding two variants that
remove the name or the subject of the form when they are active.

The variants can be activated from the widget that embeds the form.
Note that the webform field is not created with the example module,
just the webform so you need to add it manually and configure
the form display mode.

Future plans

Instead of having to write a Drupal form logic use another webform to
display in the widget and save the submission as "default_values" for
the webform that will be embedded.

Drupal 9–10 · not 11

Ask your assistant about Webform widget handler

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jul 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.0 Stable 9–10 Jul 19, 2023
1.x-dev Dev 9–11 Jul 19, 2023