1

When creating a new form in my Drupal 10 project, I would like a URL alias to be automatically be created for the form with /form/* as the prefix.

I can set pathauto rules for content types, but not web forms.

How is this done for web forms?

5
  • Tag this post with the Drupal version, like “10” or “7”.
    – mona lisa
    Commented Aug 7 at 10:10
  • 1
    @monalisa – Version tags should be used for questions that apply to a version only, not to merely say what version a site is using.
    – leymannx
    Commented Aug 7 at 10:14
  • ...and latest version (or at least 8+) is assumed in absence of a tag
    – Clive
    Commented Aug 7 at 10:25
  • 1
    I wasn’t asking idly. I asked because “/form” is the prefix on Drupal “10” by default and the question wouldn’t make sense.
    – mona lisa
    Commented Aug 7 at 10:42
  • @monalisa – Ah yes, you are absolutely right. /form prefix is the default. I added that to the answer. Maybe OP has a project where the default already got changed.
    – leymannx
    Commented Aug 7 at 11:05

1 Answer 1

3

/form already comes as the default in the webform.setting.yml#L5. Maybe it got changed in your project.

Double-check it with the following Drush command:

drush config:get webform.settings settings.default_page_base_path

To change it run the following Drush command and export config:

drush -y config:set webform.settings settings.default_page_base_path '/form' && drush -y config:export

On the edit page for a webform I also get this tooltip next to the "Webform URL alias" field:

Optionally specify an alternative URL by which the webform submit page can be accessed. Any value entered here will overwrite ALL aliases you may have created for this form via the path module. The URL alias has to start with a slash and cannot end with a slash.

Defaults to: /form/YOUR-WEBFORM-ID

This finally leads me to https://example.com/admin/config/search/path/patterns/add where I also can add a pattern for Webforms:

enter image description here

2
  • Thanks. I'm not sure what happened in this case 'webform.settings:settings.default_page_base_path': /form. A new form is created under /form.
    – Interlated
    Commented Aug 8 at 4:45
  • My pathauto settings only has: media, content, taxonomy term, user
    – Interlated
    Commented Aug 8 at 4:48

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.