Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Installing webform installs its default Contact form which is available to anonymous users. This is unfavorable when trying to use webform in distributions since the easiest way to automatically remove that page is a profile hook_install with an entity query to find the contact form then delete it.
Proposed resolution
Move `webform/config/install/webform.webform.contact.yml` to webform_demo, webform_examples, or a new webform_contact submodule to make it optional when installing webform itself.
Comment | File | Size | Author |
---|---|---|---|
#15 | webform-2888250-15.patch | 404 bytes | malcomio |
#5 | 2888250-5.patch | 553 bytes | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI think it is very important to provide a starting point for new users. Personally, I am okay with distributions manually removing the contact webform using a PROFILE_install() which can be documented in a recipe.
Finally, I actually rely on the contact form for a bunch of automated tests.
Comment #3
rjg CreditAttribution: rjg commentedThanks. I submitted a recipe.
Comment #4
malcomio CreditAttribution: malcomio at Capgemini commentedTo me it would make more sense for the default form to be created as part of the tests, rather than on module install.
Don't want to re-open an old issue, though.
The recipes at https://www.drupal.org/docs/8/modules/webform/webform-cookbook don't mention how to remove the default contact form.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedAlmost all form builders on the market include one default contact form to help get people started.
Still, what we have to love about Drupal and Open Source is that we can change anything (with a patch or fork).
I understand that a distribution or multisite setup might not want to keep the default contact form. The attached patch will automatically delete the default contact form during the webform module's installation.
@malcomio If you have time please add a recipe to the cookbook and link to this patch.
Comment #6
malcomio CreditAttribution: malcomio at Capgemini commentedThanks - I've created https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-re...
Comment #7
uberhacker CreditAttribution: uberhacker as a volunteer and commentedWhy can't we just add an option to disable the webform? Deleting the default contact form is a bad option if there were custom fields added or if the form was enabled at one point and submissions were added. In this case, you cannot simply uninstall the module. I think this should be reopened.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI stand by my comments in #2 and #6.
Drupal core is working on improving the UX for deleting content entities which contain existing records.
I am setting this issue's status back to "Closed (won't fix)" because it is an accurate summary of the previous comments.
Comment #9
uberhacker CreditAttribution: uberhacker as a volunteer and commented@jrockowitz: I respectfully disagree. I recently worked on a site where they initially enabled the contact form and decided later they wanted to disable the form but keep the current submission history. Without custom code, this is currently not possible. Sure, we could add code to hook_form_alter to `$form['#access'] = FALSE;` but I feel providing an option to the form is a more elegant solution. I'll try and submit a patch when I get some "free" time.
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@see Webforms can now be archived
Comment #11
uberhacker CreditAttribution: uberhacker as a volunteer and commentedThank you for the feedback @jrockowitz. Once a webform is archived, is it easy to "restore" back to the previous working state? I would think simply disabling the form would be "easier" if you may want to restore later?
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedArchiving is the same as unpublishing and completely safe.
Comment #13
malcomio CreditAttribution: malcomio at Capgemini commentedIn case people still want to use the patch from #5, it causes an error with later versions of webform: Cannot redeclare webform_install()
I would attach an updated patch, but the option isn't available (I guess because the issue is closed). Here's the content of the updated patch:
Comment #14
bcobin CreditAttribution: bcobin commentedWow - the default configuration looks like a real spam magnet to me - I think an option to disable the form would make the most sense.
Being able to archive the form is a help, though; unfortunately, it seems that redirect doesn't work for the /form/contact URL... or maybe I'm missing something? Odd...
There are worse things than getting a "closed to new submissions message," though - thanks for Webform and... Onwards! :)
Comment #15
malcomio CreditAttribution: malcomio at Capgemini commentedRe-rolled patch for 6.2.x branch