I have a Drupal 7 webform with a dropdown list of Products - Product A - Product B - Product C - etc...

I want to place a button link on another page "How to Buy Product A" that will bring up the webform with Product A selected in the dropdown.

The Field Key in the Webform for the dropdown is: railing_system_model

Do I just add something to the link URL??

I have no idea where to begin, is there a module that will do this?



2 Answers 2


hook_form_alter() or hook_form_form_id_alter() is what you're looking for here.

First your link how ever it's constructed should have a query parameter kind of like "/webformurl?product=a". This would be a link back to your webform.

In one of the hook form alters, you'd check for the value in the url if it doesn't exist do nothing. If it does change the default value for the form field.

If you're not sure how to alter the field on your form maybe check out this link for additional details - Programmatically modifying a webform with hook_form_alter()

  • Thanks Chad but I have no clue how to implement hook_form_alter() and the link you provided was way over my head.
    – John
    Commented Oct 6, 2016 at 18:14
  • @john have you ever made a custom drupal module?
    – Chad Payne
    Commented Oct 6, 2016 at 21:10
  • nope, can't even understand the tutorials on how to do so, way out of my league
    – John
    Commented Oct 7, 2016 at 13:25
  • What type of field is it? Commented Oct 7, 2016 at 13:49
  • WebForm Select Options Field
    – John
    Commented Oct 7, 2016 at 20:55

The Prepopulate module will let you pre-set most form values by adding a parameter to the URL corresponding with the field name. You'd use something like this (inspect your generated form for the proper variable name to use, and watch you are using the proper underlines/dashes):


  • why "node/add"? I'm just pre-selectiong a field in a webform, node adding a node
    – John
    Commented Oct 24, 2016 at 19:46
  • node/add was just an example URL. It would work on any path showing a Drupal form generated by the Form API. The key part is the ?edit[YOUR_FIELD_NAME_HERE]=YOUR_VALUE part.
    – diamondsea
    Commented Mar 9, 2017 at 22:12

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.