2

I am embedding the contacts form onto a CMS page with this bit of layout XML:

<reference name="content">
<block type="core/template" name="cmsContactForm" form_action="/contacts/index/post" template="contacts/form.phtml"></block>
</reference>

However, when I am on that CMS page this bit of code on the contacts form page:

<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">

The getFormAction() method returns an empty string, resulting in the contact form failing as it just refreshes the page instead of submitting the information in the contact form.

Can anyone tell me how to get a proper form action from getFormAction()?

Is there a relevant helper that I can employ on a CMS page?

1
  • Is this Magento 1.9? Commented Jul 5, 2022 at 6:18

2 Answers 2

0

In Magento post action for contact page is set in controller class

Mage_Contacts_IndexController

In action indexAction()

$this->getLayout()->getBlock('contactForm')
            ->setFormAction( Mage::getUrl('*/*/post', array('_secure' => $this->getRequest()->isSecure())) );

If you declare the post action in block xml

<block type="core/template" name="cmsContactForm" form_action="/contacts/index/post" template="contacts/form.phtml"></block>

You can get it in block file which you are using as core/template and you can not get it in phtml directly.

You can use directly like

<form action="<?php echo Mage::getUrl('contacts/index/post', array('_secure' => $this->getRequest()->isSecure())); ?>" id="contactForm" method="post">
2
  • But this is not an answer to the question. Do you know the answer to get the form action properly? Commented Apr 29, 2019 at 9:02
  • If you are sure this is not a correct answer to question, you must know proper answer. Commented Apr 29, 2019 at 13:29
0

Instead of core/template use contact block for get this function

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.