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') ) { ... }
Comment | File | Size | Author |
---|---|---|---|
#11 | 2942863-draft-message-11.patch | 5.59 KB | bucefal91 |
| |||
#11 | interdiff-6-11.txt | 4.89 KB | bucefal91 |
#6 | interdiff-4-5.txt | 696 bytes | bucefal91 |
#6 | 2942863-draft-message-5.patch | 992 bytes | bucefal91 |
| |||
#4 | 2942863-4.patch | 721 bytes | jrockowitz |
|
Comments
Comment #2
stuartcarruthers CreditAttribution: stuartcarruthers commentedPatch attached...
Comment #3
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedI 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).
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe 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.
Comment #5
dakku CreditAttribution: dakku as a volunteer commented@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.
Comment #6
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedNice, 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
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI 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.'
Comment #8
stuartcarruthers CreditAttribution: stuartcarruthers commentedThanks for your responses guys. Making the default message optional seems like a much simpler solution and should work well for our needs.
Comment #9
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedOkay, 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):
Out of this list I would make optional:
but that's just my 2 cents :)
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI 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.
Comment #11
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedIn 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):
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.
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedLooks good. Thanks.
Comment #15
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedMission accomplished 8-)
Comment #17
acarb CreditAttribution: acarb commentedI 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
. However this issue is now marked as fixed?
Comment #18
jweakley CreditAttribution: jweakley commentedI am also looking for a way to disable this green info box from appearing at the top of webforms.
https://imgur.com/lJsAarF
Comment #19
leymannxUh, 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.