Problem/Motivation

The Preview link in a contact form can be disabled in Manage Form display of the a contact form, but it is displayed nonetheless.

This might have to do with the the fix in #1867030: Contact message preview appears at random form position after sorting fields in Manage fields.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ifrik created an issue. See original summary.

varshith’s picture

I can confirm this issue.

On taking a closer look, the issue is that

in /core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php

we have code to get extra-fields, loop through them and set#access to FALSE

$element[$extra_field]['#access'] = FALSE;

But in case of contact forms, the preview button is present within actions. So the above line doesnt affect the 'preview' button but on clicking preivew, the preview content is present at $element['preview'] and it is hidden from view.

Something like the following in /Drupal/Core/Entity/Entity/EntityFormDisplay.php will work

if(isset($element[$extra_field])) {
  $element[$extra_field]['#access'] = FALSE;
}
else if(isset($element['actions'][$extra_field])) {
  $element['actions'][$extra_field]['#access'] = FALSE;
}

But I dont think its the best way to fix this.
If someone can point me in the right direction, I can roll up a patch for this.

Thanks

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.

Piyush_Rai’s picture

Assigned: Unassigned » Piyush_Rai

I have reproduced this issue and it can be resolve from manage from display. So i m trying to resolve it and will update with patch asap.

cchoudhary’s picture

prajaankit’s picture

Status: Active » Needs review
prajaankit’s picture

FileSize
67.74 KB
54.3 KB

Hi cchoudhary,

your patch working fine , i test that on drupal 8.5.x-dev.

more clealification in screencast.

Thanks

ifrik’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, the patch works and fixes the problem described in the issue summary.

cilefen’s picture

Component: contact.module » entity system
Issue tags: +Needs tests
cilefen’s picture

Status: Reviewed & tested by the community » Needs work

Nice work everyone, and it looks like a simple enough fix. I think we need regression tests on this. Can someone please add some?

prajaankit’s picture

Hi cilefen,

please explain more
what kind of regression tests you want
so may i help you .

prajaankit’s picture

Hi cilefen,

please explain more
what kind of regression tests you want
so may i help you .

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

larowlan’s picture