I have a contact form currently set up with select options for the nature of the customer's inquiry. The conditionals and email handlers are set up for each selection value. Just now the user has to manually select a subject from the drop down before it displays the corresponding fields. Is it possible to take the user to the form using a parameter in the URL based on the selection option value so all the relevant fields are shown? I have tried using variants and references to show the fields and display them in webform nodes but I wondered what was the best way to go about this as I cannot get the fields to hide using variants. I'm still new to variants so still working all of that out. I have looked through the previously asked questions but I can't find anything for Drupal 8.

  • 3
    Does this answer your question? How can I set a webform's field value by query parameter?
    – sonfd
    Aug 24, 2020 at 14:50
  • Thank you. I'm not sure it does everything I'm trying to achieve. I can set the default value here so the form displays all of the fields for one selection option but I have about 12 options for the user to choose from. Does this way work to pass the query into the URL of the webform itself so I can direct the user directly to the corresponding values of the webform?
    – Helen B
    Aug 24, 2020 at 15:30

1 Answer 1


If I'm understanding correctly, you want to show/hide certain fields based on the value of the Subject field, and you also want this value to have the ability to be set via a URL parameter?

If that's the case, this can be done in a single form using conditional fields and form settings.

First, in your form Settings, under Form >> Form Behaviors >> Prepopulate, check Allow all elements to be populated using query string parameters.

If this is checked, all elements can be populated using query string parameters. For example, appending ?name=John+Smith to a webform's URL would set the 'name' element's default value to 'John Smith'. Please note that individual elements can also have prepopulation enabled, so you could skip this and allow only the Subject field to be prepopulated if desired.

Next, in "Build" screen, edit one of the conditional fields that depend on the Subject field value. In the "Conditions" tab, you can describe the logic to display or hide the field based on the value of another field, something like

Visible if All of the following is met:

Subject[Select] Value Is 'Some subject value'

I hope I've understood your question correctly! While it doesn't use 'variants', this approach can still help you show a variation of your form depending on how the "Subject" field is filled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.