Advertising sustains the DA. Ads are hidden for members. Join today

Webform Cookbook

How to remove the default contact form

Last updated on
18 May 2022

By default, the webform module creates a default contact form, which is available at /form/contact

If you don't want this to be created as part of your site deployment, you can delete the form as part of the install, by applying the patch at https://www.drupal.org/project/webform/issues/2888250, or by including the following code in your module or profile's install hook:

\Drupal::entityTypeManager()->getStorage('webform')->load('contact')->delete();

In a custom module, you can also archive it in hook_modules_installed().

use Drupal\webform\Entity\Webform;

function MY_CUSTOM_MODULE_modules_installed($modules) {
  if (in_array('webform', $modules) {
    $form = Webform::load('contact');
    $manager = \Drupal::service('plugin.manager.action');
    $manager->createInstance('webform_archive_action')->execute($form);
  }
}

Help improve this page

Page status: No known problems

You can: