druxt.js icon indicating copy to clipboard operation
druxt.js copied to clipboard

Add support for the Webform module

Open Decipher opened this issue 4 years ago • 5 comments

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

Decipher avatar Oct 11 '21 10:10 Decipher

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

image

davidferlay avatar Oct 11 '21 12:10 davidferlay

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

Decipher avatar Jan 04 '22 02:01 Decipher

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.

image

Decipher avatar Jan 05 '22 02:01 Decipher

Sounds good @Decipher ! I'll have a deeper look at the code and gitpod soon

davidferlay avatar Jan 05 '22 08:01 davidferlay

Looks good ! A shame that code is needed for every webform element though

Vue is throwing a minor error btw in gitpod btw image

davidferlay avatar Jan 10 '22 13:01 davidferlay