I created my webform to accept parameters via a standard $_GET and this works fine but is quite unsecure I am told and should rather use clean URL's via Drupal 8 built in Routing.

As such I set up a module to support my webform and contains only a info.yml and routing.ynl. The routing is as below, I got the format from Using parameters in routes but suspect I just haven't grasped it.

  path: /form/enquire/{type}/{region}/{destination}
    _permission: 'access content'
    type: 'tailor-made-holidays'

Normal form access is via http://abcsite.localhost/form/enquire

Form access with parameters as a get (For illustration) was: http://abcsite.localhost/form/enquire?type=tailor-made-holidays&region=asia&destination=48

Module name is: abc_enquire_form_routing

Trying to access the form with the module enabled with the above routing through http://abcsite.localhost/form/enquire/tailor-made-holidays is simply giving me a p "The requested page could not be found." error. So I can only assume I am doing the routing wrong.

What I am trying to achieve is three optional parameters after the "http://abcsite.localhost/form/enquire" page of the url, e.g. http://abcsite.localhost/form/enquire/tailor-made-holidays/asia/49

Can anyone point me in the direction of a good example of doing this with webforms module ?

  • Routes can't support query string parameters. You might need to define a route for each variant. abc_enquire_form_routing.webform --abc_enquire_form_routing.webform.type -- abc_enquire_form_routing.webform.type.region – jrockowitz Nov 6 '17 at 20:47
  • @jrockowitz - Thanks, I was trying to actually do away with Querystring params, and switch to a purely RESTful method of passing parameters within the route, but I cannot get the route working if I add parameters as shown above. – John Cogan Nov 8 '17 at 9:12

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.