cancel
Showing results for 
Search instead for 
Did you mean: 

Insert Contact form in page or block

SOLVED

Insert Contact form in page or block

Hi

Like to insert the standard contact form in some block or pag eeditor.

 

Try to insert this in HTML view

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}

But nothing showed...

Can you help me?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Insert Contact form in page or block

Hi @trevo

 

Yes , that is correct because  Captcha is a separate module with its own block

 

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Captcha/Block/Captcha.php

 

The captcha module then specifically observes that pages that it wishes to protect and adds a check in for the correct captcha on that form:

 

https://github.com/magento/magento2/tree/2.2-develop/app/code/Magento/Captcha/Observer

 

The event observer for the regular contact form is set up here:  https://github.com/magento/magento2/blob/9c14af7a97bcf338662de365d2613c7ca9dbf8c6/app/code/Magento/C...

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

View solution in original post

3 REPLIES 3

Re: Insert Contact form in page or block

OK sorry,

the solution is this:

Paste this code not in HTML mode and save,

but in preview mode of block or page...

Re: Insert Contact form in page or block

Now the problem is that in that page where put this code not show the captcha... and when try to send redirect to contact page and show an error that capcha is not correct.

 

How can show capcha i all forms that i put in page with this code?

Thanks.

Re: Insert Contact form in page or block

Hi @trevo

 

Yes , that is correct because  Captcha is a separate module with its own block

 

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Captcha/Block/Captcha.php

 

The captcha module then specifically observes that pages that it wishes to protect and adds a check in for the correct captcha on that form:

 

https://github.com/magento/magento2/tree/2.2-develop/app/code/Magento/Captcha/Observer

 

The event observer for the regular contact form is set up here:  https://github.com/magento/magento2/blob/9c14af7a97bcf338662de365d2613c7ca9dbf8c6/app/code/Magento/C...

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution