<p>Hi everybody!
I already read around here a lot and mostly found an answer to my questions. Thank you for that already!
Now I'm stucked on a problem for a week already. We have different pages for services. On each page we integrated a contact form.
While reviving an email of the contact form it doesn't say now which service the customer is interested in.
In magento 1 I solved it with different contact forms with different subjects.
Now we would prefer if the subject field is not shown in the frontend, but the service (could also be pagetitle) is the subject of the emails.
When integrating a contact form I cant use a different template than the standard form.
That is the code I integrate on the CMS pages:
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::serviceform.phtml"}}
I see two options, which I don't get to work
1) Implement a hidden subject in the form (form.phtml)
-> Magento 2 uses the subject of the template
2) Use an individuell template
-> can't call it in the block on the cms pages individuelly
Is there somebody who has a solution for that?
technical data:
Magento version: 2.3.2.
template: porto
Thank you
Chris</p>
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::serviceform.phtml" subject="xxxxxxxxxx"}}
Do pass Hidden fields in contact forms
<input type="hidden" name="subject" value="<?php echo $this->getSubject(); ?>" />
In Contact form controller require which sending email to set that subject by getting subject and passing in email template,
$subject = $this->getRequest()->getParam("subject");
This variable you need to set subject whichever you would like to set and do pass in email template functions
Hi Bhavesh Surani,
thanks for your help!
I've done like you say. But I'm not to sure if I got you right at the last part:
In Contact form controller require which sending email to set that subject by getting subject and passing in email template,
$subject = $this->getRequest()->getParam("subject");
This variable you need to set subject whichever you would like to set and do pass in email template functions
I added it there:
But the Email subject is just one to one this code. I tried with and without brackets.
Thanks Chris