5

in magento 1.x for add contact form in CMS page i use next code

{{block type="core/template" name="contactForm" form_action="{{store direct_url='contacts'}}/index/post" template="contacts/form.phtml"}}

How I can add contact form in CMS page in magento 2

2 Answers 2

23

Call your contact form block with template file in the cms pages.

Try below code :

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
3
  • Any ideas how to stop it from redirecting back to contact/index/index on form submission. Would be nice to just submit the form, and remain on the page with the contact block in it? May 19, 2019 at 22:17
  • @GrahamWharton - Then you need do some workaround with Ajax based form submission. May 20, 2019 at 5:59
  • @GrahamWharton I'm sorry for bumping up this old answer. But maybe you cold put a redirect on "contact/index/index" to the page that your contact form is on. Of course this would only be an option if you want your page to replace the default contact page.
    – jrswgtr
    Jun 2, 2023 at 8:35
5
{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.