I'm trying to create an additional contact form and am running into an issue - initially I modified the default contacts form but ran into issues so tried just using the default contact form on a CMS page, using the following code:

{{block type='core/template' template='contacts/form.phtml'}}

but whenever I try to submit the form it produces the following error

Fatal error: Call to a member function setFormAction() on a non-object in /home/urider/web/app/code/community/Fontis/Recaptcha/controllers/ContactsController.php on line 32

line 31,32 is as follows:

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

From what I've seen online it may be something to do with the layout not being loaded but I'm really not sure, any thoughts?


Just change form action in full format:

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

Change form action: `action="<?php echo Mage::getUrl('contacts/index/post') ?> "`
  • Thanks for the quick reply, is there any potential for this screwing anything up in the future? Edit: I just tried this and it broke the contact form on the /contactus/ page (it produced the same error that was occurring on the cms page contact form)
    – eddhall
    Feb 10 '15 at 11:04
  • form.phtml file change the action to Mage::getUrl('contacts/index/post')
    – Amit Bera
    Feb 10 '15 at 11:09
  • Hey Amit, Sorry I should have added, it didn't fix the original problem anyway, the form action in both contact forms is: "<?php echo $this->getFormAction() ? $this->getFormAction() : '/contacts/index/post/'; ?>"
    – eddhall
    Feb 10 '15 at 11:21
  • "<?php echo Mage::getUrl('contacts/index/post')?>" just do this .. no need to set <?php echo $this->getFormAction() ? $this->getFormAction() : '/contacts/index/post/'; ?>
    – Amit Bera
    Feb 10 '15 at 11:23
  • Sorry it's still producing the same fatal error for both contact forms
    – eddhall
    Feb 10 '15 at 11:32

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.