Setting the label display to "hidden" or "visually hidden" in the Contact Forms configuration does not seem to have any effect on the field label.

To reproduce:

  1. On a standard install
  2. Change the Message field label of the Feedback form to be hidden (/admin/structure/contact/manage/feedback/display)
  3. Go to the Feedback form at /contact/feedback
  4. Enter dummy title and message content and press Preview
  5. Notice that the Message label is visible.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexbea created an issue. See original summary.

alexbea’s picture

Issue summary: View changes
pareshpatel’s picture

It seems that it's not an issue with Contact Block module. It should be the issue in Core Contact Module.

I have checked the core contact form and manage display setting for labels and it is not working.

Sutharsan’s picture

Title: Block does not follow field label display config » Label of contact form message field is not hidden
Project: Contact Block » Drupal core
Version: 8.x-1.2 » 8.3.x-dev
Component: Code » contact.module
Issue summary: View changes

Moving the issue from Contact Module to Drupal core. Fault still exists on 8.3.x.

Berdir’s picture

That's because the message is still hardcoded in the viewbuilder and assumes it is an extra field when it is actually not.

Removing that fixes this.

Also looks like we had zero tests for preview? Which looks laughably bad, but that's another problem.

claudiu.cristea’s picture

Status: Needs review » Needs work

I wonder why message was considered an extra field. Are there some reasons?

However...

  1. +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
    @@ -339,6 +340,33 @@ function testSiteWideContact() {
    +    $edit = array(
    

    I see below, we're using the square brackets. Let's use also here the square brackets syntax.

  2. +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
    @@ -339,6 +340,33 @@ function testSiteWideContact() {
    +    $this->drupalPostForm('contact/' . $contact_form, $edit, t('Preview'));
    

    $form->toUrl() instead of hardcoding the path, as is the canonical path.

  3. +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
    @@ -339,6 +340,33 @@ function testSiteWideContact() {
    +
       }
    

    Extra empty line before end of method.

claudiu.cristea’s picture

More...

+++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
@@ -339,6 +340,33 @@ function testSiteWideContact() {
+    $this->assertText(t($edit['message[0][value]']));
...
+    $this->assertText(t($edit['message[0][value]']));

These are looking wrong. The entity field should not be passed to t().

Also @klausi told me at some point that we should not use t() anymore in tests, not even for buttons, not even in simpletest. I read this somewhere but I can't find the page.

Berdir’s picture

Issue tags: +Novice

Because message used to be an extra field.

Sorry for those copy paste errors, should be an easy Novice task to fix them.

jeevanbhushetty’s picture

Assigned: Unassigned » jeevanbhushetty

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.

aroua_safa’s picture

I'm going to review it

aroua_safa’s picture

Status: Needs work » Reviewed & tested by the community

I made a review on 8.1, 2, 3 and 4.x versions and confirm that the patch work.

Berdir’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for testing, but someone still needs to address #6.

arunkumark’s picture

Status: Needs work » Needs review
FileSize
3.23 KB

Hi,

As per comment #6 and #7 i have updated the patch.

claudiu.cristea’s picture

@arunkumark, please post an interdiff

Status: Needs review » Needs work

The last submitted patch, 14: contact-message-title-2756689-14.patch, failed testing.

arunkumark’s picture

Assigned: jeevanbhushetty » Unassigned
Status: Needs work » Needs review
FileSize
2.82 KB

Re-rolled patch.

@claudiu.cristea can't apply the patch file contact-message-title-2756689-5.patch so the problem in the creation of the interdiff file.

claudiu.cristea’s picture

Status: Needs review » Needs work

@claudiu.cristea can't apply the patch file contact-message-title-2756689-5.patch so the problem in the creation of the interdiff file.

In such cases, you do first a reroll, commit in a temp branch. Then you apply the changes and run a diff against that intermediary branch, so you get the interdiff.

+++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
@@ -315,11 +316,11 @@ function testSiteWideContact() {
-    $edit = array(
+    $edit = [
...
-    );
+    ];

@@ -335,11 +336,11 @@ function testSiteWideContact() {
-    $edit = array(
+    $edit = [
...
-    );
+    ];

Unrelated changes. Revert them.

And the big problem is that you removed the test from #5.

tameeshb’s picture

Status: Needs work » Needs review
FileSize
1.69 KB

Corrected patch from #17 As recommended in #18

Berdir’s picture

Status: Needs review » Needs work

You lost the test coverage in that reroll. Compare with the previous patches.

claudiu.cristea’s picture

@tameeshb, as I said in #18, the patch removed the test from #5. So, please:

  • Start a patch from #5,
  • Do a reroll
  • Apply changes from #6, #7.
  • Create and post also an interdiff of those changes, so the reviewers can track what has been changed.

Thank you.

tameeshb’s picture

Assigned: Unassigned » tameeshb

Alright, but the interdiff is to be done with which patch? #5?

claudiu.cristea’s picture

@tameeshb, yes, please do it against #5.

tameeshb’s picture

Status: Needs work » Needs review
FileSize
4.68 KB
3.29 KB

Patch form #5 revised, please review! :)

tameeshb’s picture

Missed out on a ']' in the last patch, corrected and uploaded with interdiff against #5

The last submitted patch, 24: 2756689-24.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 25: 2756689-25.patch, failed testing.

claudiu.cristea’s picture

@tameeshb, thank you.

  1. +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
    @@ -293,11 +294,11 @@ function testSiteWideContact() {
    -    $edit = array(
    +    $edit = [
    ...
    -    );
    +    ];
    
    @@ -315,11 +316,11 @@ function testSiteWideContact() {
    -    $edit = array(
    +    $edit = [
    ...
    -    );
    +    ];
    
    @@ -335,15 +336,41 @@ function testSiteWideContact() {
    -    $edit = array(
    +    $edit = [
    ...
    -    );
    +    ];
    

    Unrelated changes. Please revert them.

  2. +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
    @@ -335,15 +336,41 @@ function testSiteWideContact() {
    +    $this->drupalPostForm('contact/' . $contact_form, $edit, t('Preview'));
    

    #6.2 is not addressed.

  3. +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
    @@ -335,15 +336,41 @@ function testSiteWideContact() {
    +    $this->drupalPostForm($form->toUrl() . $contact_form, $edit, t('Preview'));
    

    This is wrong. You should not append $contact_form. Only $form->toUrl() should be passed as argument.

tameeshb’s picture

Status: Needs work » Needs review
FileSize
2.73 KB
3.21 KB

Status: Needs review » Needs work

The last submitted patch, 29: 2756689-29.patch, failed testing.

geertvd’s picture

Status: Needs review » Needs work

The last submitted patch, 31: label_of_contact_form-2756689-31.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
3.22 KB
Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. This was originally my patch, but has been RTBC before and reviewed by others too.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 33: label_of_contact_form-2756689-33.patch, failed testing.

claudiu.cristea’s picture

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

And because this is a bugfix with no API implications, this should be fixed in 8.3.x.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

And back to RTBC, thanks for the reroll and updates.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Less code. More tests. Yay.

Committed and pushed e27d0da to 8.4.x and bbbb980 to 8.3.x. Thanks!

  • alexpott committed e27d0da on 8.4.x
    Issue #2756689 by tameeshb, geertvd, arunkumark, claudiu.cristea, Berdir...

  • alexpott committed bbbb980 on 8.3.x
    Issue #2756689 by tameeshb, geertvd, arunkumark, claudiu.cristea, Berdir...

Status: Fixed » Closed (fixed)

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

kenheim’s picture

I'm using 8.3.2 and this is still an issue.

sajosh’s picture

Field label is not getting Hidden, Visibly Hidden, nor Inline for me either.

drupal 8.4.3 upgraded from D6
PHP Version 7.1.12
Memory limit 524M
Database Version 5.5.58-0+deb7u1-log

I verified that all the changes in patch #36 are in my 8.4.3 core files.
I tested this on a clean D8 install too but field label is still only Visible.
I also tested if the field is 'not required', but alas, still only visible.

Do you want me to test anything?