0

I called contact form in my .phmtl page using this code:

<?php include ($block->getTemplateFile('Magento_Contact::form.phtml')) ?>

The problem is when I click on submit, there's no success message and we don't receive the mail by consequence.

PS:when I try mywebsite.com/contact it works correctly

  • when I try mywebsite.com/contact it works correctly – Nouari zineb Jun 24 '19 at 16:25
  • what do you mean exactly please! – Nouari zineb Jun 24 '19 at 16:53
  • Hey, check the form action @Nouarizineb – Prathap Gunasekaran Jun 24 '19 at 16:54
  • <form class="form contact" action="<?php echo $block->getFormAction(); ?>" id="contact-form" method="post" data-hasrequired="<?php /* @escapeNotVerified / echo __(' Required Fields') ?>" data-mage-init='{"validation":{}}'> – Nouari zineb Jun 24 '19 at 16:57
  • <?php echo $block->getFormAction();die; ?> and check before form – Prathap Gunasekaran Jun 24 '19 at 17:01
1

Please can U try this way to call form.phtml in your phtml file.

<?php echo $this->getLayout()->createBlock("Magento\Contact\Block\ContactForm")->setTemplate("Magento_Contact::form.phtml")->toHtml(); ?>

hope this helpful

| improve this answer | |
1

Use Below code direct into phtml file

<?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Contact::form.phtml")->toHtml(); ?>
| improve this answer | |
  • Thank you! it works perfectly – Nouari zineb Jun 25 '19 at 9:04
  • Thank you @Nouarizineb . – Shorabh Jun 25 '19 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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