Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#7 | 2018-01-24_1338.png | 54.3 KB | prajaankit |
#7 | 2018-01-24_1336.png | 67.74 KB | prajaankit |
#5 | hide-extra-fields-action-button-2920471-5.patch | 760 bytes | cchoudhary |
Comments
Comment #2
varshith CreditAttribution: varshith as a volunteer commentedI 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
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
Comment #4
Piyush_Rai CreditAttribution: Piyush_Rai commentedI 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.
Comment #5
cchoudhary CreditAttribution: cchoudhary at ]init[ AG commentedHere's a patch:
Comment #6
prajaankit CreditAttribution: prajaankit at ]init[ AG commentedComment #7
prajaankit CreditAttribution: prajaankit at ]init[ AG commentedHi cchoudhary,
your patch working fine , i test that on drupal 8.5.x-dev.
more clealification in screencast.
Thanks
Comment #8
ifrikThanks, the patch works and fixes the problem described in the issue summary.
Comment #9
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedComment #10
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedNice work everyone, and it looks like a simple enough fix. I think we need regression tests on this. Can someone please add some?
Comment #11
prajaankit CreditAttribution: prajaankit at ]init[ AG commentedHi cilefen,
please explain more
what kind of regression tests you want
so may i help you .
Comment #12
prajaankit CreditAttribution: prajaankit at ]init[ AG commentedHi cilefen,
please explain more
what kind of regression tests you want
so may i help you .
Comment #16
larowlanthis was fixed in #2960353: Make the Preview button on the Contact Forms to obey the "Manage form display" field settings