druxt.js
druxt.js copied to clipboard
Add support for the Webform module
Is your feature request related to a problem? Please describe. As a user I want the ability to display forms build with the Webform module in Druxt
Describe the solution you'd like
- [ ] Create a custom Webform module for Druxt
Describe alternatives you've considered N/A
Additional context
- https://www.drupal.org/project/webform
FYI there is a json:api endpoint exposing webform configs :
curl --location --request GET 'http://172.19.0.4/jsonapi/webform/webform/'- it requires permission Access any webform configuration
There is also /jsonapi/webform_options/webform_options endpoint that provides the values of pre-defined select list webform elements (it's a distinct config item in webform module). Funny enough, it requires a different permission: Administer webform

Thanks for the additional information @davidferlay,
I did look into this atleast once, and did get a working prototype, but for whatever reason I didn't commit it. I will revisit this in a future Druxt Office Hours
I've put together my initial prototype of Druxt with Webform: https://github.com/Decipher/druxt-experiments/tree/feature/webform
Gitpod: https://gitpod.io/#github.com/Decipher/druxt-experiments/tree/feature/webform
Currently it will render a Webform attached to a Webform node. As Webforms are content entities, it should also be possible to render a detached webform.
The Webform elements are parsed using js-yaml and the data is then fed into a custom DruxtWebformElements modules that renders the fields with support for DruxtWrapper components. E.g., DruxtWebformElementTextfield.
I haven't yet attempted to submit or handle the data, but I will followup when I continue with the experiment.

Sounds good @Decipher ! I'll have a deeper look at the code and gitpod soon
Looks good ! A shame that code is needed for every webform element though
Vue is throwing a minor error btw in gitpod btw
