0

Drupal 8 - Module: Webform ( https://www.drupal.org/project/webform )

I have a web form design that starts with three buttons at the top. Depending on which one is clicked, the form changes. One page is common to all three and all three have an extra page which is specific to itself only.

The pages which are specific to a button has elements which are "required".

I initially built the web form as three separate web forms and the buttons at the top simply redirected to the correct web form. The problem here is that the common page ("About you") had to be recreated 3 times and also resulted in the submissions been split across three separate sections.

In the current Drupal 8 version of Webform, hardly any of the libraries that extend it are not available for Drupal 8.

What would be the best way to integrate this web form into a single form. Hiding/showing sections can be done easily enough using simple CSS and/or jQuery but the issue is that if a section of the form which is hidden has a required form element, on submission the form validates falsely.

Is there are a way to conditionally turn off the required status of an element based upon the buttons selected at the top?

  • 1
    The webform has a 'Buttons element' which you can be used to trigger conditional hide/show and required logic for pages and elements. BTW, most Webform for Drupal 7 sub-modules are not really needed for D8.... and people are waiting for a stable release of Webform for D8 to start porting their modules – jrockowitz Oct 24 '17 at 19:23
  • Thanks for your reply @jrockowitz, I just discovered this option this morning. Just the conditional validation to figure out now, which I will use form alter for. – John Cogan Oct 25 '17 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.