I am using this module in a complex project involving multiple forms. To allow users to save their work and return to it later the forms utilise the drafts functionality built into Webform.

However, in user testing it has been noted that the "pending draft" messages can be confusing to users of the application, so it would be very useful to have the ability to disable these messages on a form-by-form basis, keeping the draft functionality under the hood.

A proposed solution is to add a checkbox to the form settings which allows these messages to be suppressed even if drafts are enabled:

This patch introduces a new form config setting called draft_suppress_message which defaults to FALSE. This setting is then used in two places within WebformSubmissionForm.php to prevent the message from being displayed:

// Display loaded or saved draft message.
if ($webform_submission->isDraft() && !$this->getWebformSetting('draft_suppress_message')) {
  ...
}

...and...

// Display link to multiple drafts message when user is adding a new
// submission.
if ($this->isGet()
  && $this->getWebformSetting('draft') !== WebformInterface::DRAFT_NONE
  && $this->getWebformSetting('draft_multiple', FALSE)
  && ($this->isRoute('webform.canonical') || $this->isWebformEntityReferenceFromSourceEntity())
  && ($previous_draft_total = $this->storage->getTotal($webform, $this->sourceEntity, $this->currentUser(), ['in_draft' => TRUE]))
  && !$this->getWebformSetting('draft_suppress_message')
) {
  ...
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stuartcarruthers created an issue. See original summary.

stuartcarruthers’s picture

bucefal91’s picture

I might have just a different way of thinking, but.. wouldn't it be just more straightforward logic to have a checkbox "Enable notification about pending draft"? And then if the checkbox is enabled, the whole textarea should be visible? It just feels a little more straight to me to optionally opt-in (enable) instead of optionally opt-out (suppress).

jrockowitz’s picture

Status: Active » Needs review
FileSize
721 bytes

The question is.. how many people really need to disable the pending draft message?

The D7 version of the webform module has a hardcode message that can only be removed using a custom module.

The attached patch makes the default draft message optional.

dakku’s picture

@jrockowitz - thanks for sharing the "hidden" setting, I think this would work..

Whilst I agree, many sites would either need the message, or wouldnt care, in our circumstances however, we needed to hide the message for various guidelines and requirements. Thanks again for sharing your patch.

bucefal91’s picture

Nice, this non-required is even smarter :)

I confirm your patch works. And then I also suggest to keep consistent, let's make "Default draft save message" non-required too.

I attach the patch that does it on top of Jacob's patch in #4

jrockowitz’s picture

I think this might a good opportunity to not require any default message that is not critical.

For example, should a site be required to include a 'Default open message' and 'Default close message.'

stuartcarruthers’s picture

Thanks for your responses guys. Making the default message optional seems like a much simpler solution and should work well for our needs.

bucefal91’s picture

Okay, I've glanced through the UI of settings in the module and found the following required messages (I specify their current value in my dummy Drupal just to make it easier to understand what they refer to):

  • Default open message: This form has not yet been opened to submissions.
  • Default closed message: Sorry...This form is closed to new submissions.
  • Default exception message: Unable to display this webform. Please contact the site administrator.
  • Default confidential message: This form is confidential. You must Log out to submit it.
  • Default login message when access denied to webform: Please login to access this form.
  • Default confirmation message: New submission added to [webform:title].

Out of this list I would make optional:

  • Default open message
  • Default closed message
  • Default login message when access denied to webform
  • Default confirmation message

but that's just my 2 cents :)

jrockowitz’s picture

I would also make the below optional...

Default total submissions limit message
Default per user submission limit message

...which will allow a webform to be completely removed once the submission limit is reached.

bucefal91’s picture

In this attached patch the following messages are made optional (each one is manually tested by me and confirmed not to display any kind of ugly empty message boxes):

  1. Default open message
  2. Default closed message
  3. Default login message when access denied to webform
  4. Default draft save message
  5. Default draft load message
  6. Default confirmation message
  7. Default total submissions limit message
  8. Default per user submission limit message

The list above is basically a union of Jacob's, stuartcarruthers's and my messages. For some messages I did have to slightly tweak the code that shows them in order not to show empty message boxes.

As far as I can see, this is a commit ready thing.

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Thanks.

The last submitted patch, 2: 2942863-disable-draft-messages.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • bucefal91 committed 043c1cb on 8.x-5.x
    Issue #2942863 by jrockowitz, bucefal91: Making some of the messages/...
  • bucefal91 committed 40c27c6 on 8.x-5.x
    Issue #2942863 by jrockowitz: Marking as non-required default draft load...
  • bucefal91 committed b897a6a on 8.x-5.x
    Issue #2942863 by bucefal91: Making another draft wording also optional.
    
bucefal91’s picture

Status: Reviewed & tested by the community » Fixed

Mission accomplished 8-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

acarb’s picture

I can't see an option in the webform version RC16 to suppress the "Pending Drafts" message as mentioned in the original issue?

WebformMessageManagerInterface::DRAFTS_PREVIOUS

The message is hardcoded in the Webform Message Handler

You have pending drafts for this webform

. However this issue is now marked as fixed?

jweakley’s picture

I am also looking for a way to disable this green info box from appearing at the top of webforms.
Only local images are allowed.
https://imgur.com/lJsAarF

leymannx’s picture

Uh, this took me quite a while of digging through the code. You can have this message configured for every single webform, but when it's empty it falls back to the global message which can be configured at /admin/structure/webform/config/submissions#edit-draft-settings. Empty it there and you get rid of it completely.