Until a recent commit, submitting a contact form would display a "Your message has been sent." message to the user. This message is now configurable when creating/editing a contact form but, by default, no message is shown/set. As discussed in #2780763: Add missing parameter in ContactFormCloneForm::__construct(), we think that this is a UX regression and that the "Your message has been sent." message should be shown/set by default.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bambell created an issue. See original summary.

Berdir’s picture

This is actually a follow-up of #306662: Add redirect option to site-wide contact forms. thanks for creating.

hussainweb’s picture

Status: Active » Needs review
FileSize
838 bytes

Here is an attempt at this. This means that the message can never be blank, which kind of makes sense. The default message will be shown even if it is blank in the contact form settings.

Berdir’s picture

I think not having a message is fine.

I wouldn't add a fallback there, just in the settings form. For a new form, set this value. if it is an existing form that has no value, then that is fine.

alexpott’s picture

Status: Needs review » Needs work

I agree with @Berdir

hussainweb’s picture

Status: Needs work » Needs review
FileSize
792 bytes

Yes, when I actually saw the UI, the description said 'Leave blank for no message'. So, updating the patch to write to the form instead.

alexpott’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Let's add some test coverage for this.

The last submitted patch, 3: contact_form_submission-2786085-3.patch, failed testing.

hussainweb’s picture

I don't think the tests are particularly of high value but here goes.

The last submitted patch, 9: contact_form_submission-2786085-8-tests-only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: contact_form_submission-2786085-8.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
FileSize
1.63 KB

This should fix the tests.

andypost’s picture

+++ b/core/modules/contact/src/ContactFormEditForm.php
@@ -97,7 +97,7 @@ public function form(array $form, FormStateInterface $form_state) {
+      '#default_value' => !$contact_form->isNew() ? $contact_form->getMessage() : $this->t('Your message has been sent.'),
       '#description' => $this->t('The message to display to the user after submission of this form. Leave blank for no message.'),

There will be always default for new forms, so "Leave blank" is wrong

hussainweb’s picture

@andypost,

There will be always default for new forms, so "Leave blank" is wrong

Are you sure about that? See this snippet of code:

    if ($submission_message = $contact_form->getMessage()) {
      drupal_set_message($submission_message);
    }

So, it is possible for the message to be blank. I don't see anything in the save logic to set the message to a default value.

Berdir’s picture

Status: Needs review » Needs work

I would suggest we change \Drupal\contact\Tests\ContactSitewideTest::addContactForm() do make the message default NULL and only add it to $edit if one is provided ('' needs to be a valid, explicitly empty string). That should give us more test coverage of this as well.

Also, I suggest you put it in ContactSitewideTest, this is specifically to being able to store messages.

And #14 is correct, but it would be good to have explicit test coverage for that if we don't have it yet.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.