Closed (fixed)
Project:
Drupal core
Version:
9.1.x-dev
Component:
contact.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Apr 2018 at 11:40 UTC
Updated:
27 Jan 2021 at 12:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
cilefen commentedComment #3
alena_stanul commentedI investigated the problem. Really admin/structure/contact/manage/feedback/form-display we see 'Preview sender message'. After disabling in Manage display we see it in contact form. The same situation is for version Drupal 8.6.0-dev.
For display this button 'Preview' in Manage displays is responsible contact_entity_extra_field_info() in contact.module.
2 ways to solve the problem to not be confused:
1) to remove
$fields['contact_message'][$bundle]['form']['preview'] = [
'label' => t('Preview sender message'),
'description' => t('Preview'),
'weight' => 40,
];
2)to finish customization for this form element in Manage display.
Comment #4
alena_stanul commentedComment #5
alena_stanul commentedComment #6
MrMason commentedI've moved the declaration of the preview button to inside the form() function instead of the actions() function.
Comment #7
cilefen commentedComment #8
alena_stanul commentedI tested your patch. It works. But the code changes affected the location of the buttons(please see The effect of the patch on the location of the buttons.png).I wrote a new patch, that removes this effect and returns the buttons Send and Preview to one line.
Comment #9
alena_stanul commentedComment #11
alena_stanul commentedWere fixed code standarts.
Comment #12
MrMason commentedAlena,
The code you submitted overwrote the existing statements for the preview array element. Let me update this.
Comment #13
ckaotikIt's quite unusual to control action visibility with the form display mode.
How about this approach? It keeps the form actions in their separate section and simply checks the form display for its configuration.
The only thing I'm unsure about is whether the form_display object is always available in the form state. But I don't see why it shouldn't be there.
Comment #14
ckaotikComment #15
jidrone commentedI tested #13 in Drupal 8.5.3 and it worked.
Comment #16
borisson_This will need tests before it can go in.
Comment #17
mgstablesI used Patch from #13 in Drupal 8.5.4 and it worked.
Comment #19
ñull commented#13 patched 8.6.10 correctly.
Comment #21
honza pobořil commentedPatch #13 works with 8.7.2
Comment #23
mherman-pro commentedPatch #13 works with 8.8.1
Disabling "Preview sender message" in the form display removes the preview button from the contact form and re-enabling it restores it on the contact from and allows you to preview the message as normal. This was tested on the default contact form and a new form created with an added field.
Comment #24
opiAnother approch using the
#accesskey for the preview element, allowing contrib or custom code to still update this element.Comment #25
mherman-pro commentedPatch #24 works with 8.8.1
I ran the same tests I detailed in post #23.
Comment #26
daften commentedJust tested this, and it looks good, but as per #16, this still needs tests.
Comment #27
jaesperanza commentedPatches work on latest D8 to date, but until a patch has been committed, I will be using Hide Preview Button https://www.drupal.org/project/hide_preview works well for other form pages, too. In case, this helps those not comfortable with working with hooks and patches.
Comment #28
maxmendez commentedI've tested patch #23 on Drupal 8.8.5 and works as a charm.
Comment #30
soaratul commentedPatch #13 works with 8.8.5
Comment #31
munish.kumar commentedComment #32
munish.kumar commentedHi,
Patch #24 looks good to me, I have tested this patch on drupal 9.x branch and it works as expected. here you will find the screenshots before and after apply patch.
Comment #33
munish.kumar commentedComment #34
pankaj.singh commentedComment #35
pankaj.singh commentedTested on 9.1.x
Patch Worked for me.
Comment #36
sivaji_ganesh_jojodae commentedPatch #24 with a test.
Comment #38
sivaji_ganesh_jojodae commentedComment #39
munish.kumar commentedHi @DevJoJodae, I have reviewed your patch and found there are some deprecated code exists in your patch, So updating the patch accordingly and providing the interdiff for the same. See also https://www.drupal.org/node/3129738
Comment #40
pankaj.singh commentedComment #41
pankaj.singh commentedTested the patch given in #39. Patch worked for me.
Please refer the screeshots attached.
Comment #43
bserem commented#39 works for me too and also applies to D8 without problems.
Comment #46
siramsay commentedRTBC
#39 works applied to 9.1.2
edit
See it was committed so that is good, thanks
Comment #47
catchCommitted/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!