Search code examples
phpmagentomagento-1.7magento-1.8magento-1.9

Contact us page error in magento


I am new to magento, I have installed one extension for captcha in contact us page from http://www.magentocommerce.com/magento-connect/contacts-form-captcha.html but it is community addition and mine is enterprise.

When i visit the contact us page it shows the error in index controller in my installed module and after i have removed the folder(recaptcha) from my community folder and related xml files also i have removed. But now it's showing the error like

Fatal error: Call to a member function setFormAction() on a non-object in /var/www/myapp/app/code/core/Mage/Contacts/controllers/IndexController.php on line 55

And the code in line 55 is

$this->getLayout()->getBlock('contactForm')->setFormAction(Mage::getUrl('*/*/post'));

Please help me to view contact us page.


Solution

  • I got the mistake what i did and the problem is in my layouts/contacts.xml file.

    I am calling the block in my index controller but that block not existed in layout

    $this->getLayout()->getBlock('contactForm')->setFormAction(Mage::getUrl('*/*/post'));
    

    'contactForm' block missed in layout

        <contacts_index_index translate="label">
                <label>Contact Us Form</label>
                <reference name="head">
                    <action method="setTitle" translate="title" module="contacts"><title>Contact Us</title></action>
                </reference>
                        <reference name="content">
                    <block type="core/template" name="contactForm" template="contacts/form.phtml">
                </reference>
    
     </contacts_index_index>
    

    After adding the above code my problem is solved.