Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Fatal error: Call to a member function setFormAction() on a non-object
 
REDMobile
Member
 
Avatar
Total Posts:  42
Joined:  2008-09-15
 

I’ve created a module ‘Affiliate’ based on the contacts module. It is a form where users can enter their information to apply to the affiliate program. I copied the code/Mage/Contacts to code/local/Affiliate and replaced all ‘contacts’ with ‘affiliate’.

I created the front end page /affiliate/form.html

I created the layout file affiliate.xml (again copying the contacts.xml)

I created the app/etx/Mage_Affiliate.xml file

When I goto the url /affiliate i get this error:

Fatal error: Call to a member function setFormAction() on a non-object in app\code\core\Mage\Affiliate\controllers\IndexController.php on line 55

Please help! I see on the boards that some people get this error after upgrading on the contacts page but I dont see any solutions.

 
Magento Community Magento Community
Magento Community
Magento Community
 
wdchoi
Jr. Member
 
Total Posts:  20
Joined:  2008-11-17
 

hi spygyrrl.

the problem here is that on line 55 of IndexController, the getBlock() method can’t find the block ‘contactForm’, or maybe in your case, the ‘affiliateForm’. Thus, the block isn’t loaded, and the method can’t be called on it…

Try to find your own block and see why it is not loaded. In the layout xml file, you will find the “contactForm” block. You can call it “affiliateForm” for instance, and put the path/to/your/template.phtml in the template property.

Dont forget to configure your own package and theme in the backend administration, and then put your templates in app/design/your_package/your_template/template/affiliate/form.phtml. I see you’ve put .html, not .phtml, careful with this too, as you have to fill the template path/filename in the affiliateForm block in the xml layout file.

I’m sorry I might be too confusing. Ask me if you need more details.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cgfc
Sr. Member
 
Avatar
Total Posts:  92
Joined:  2008-08-29
Montevideo, Uruguay
 

Hi azn_david,I have the same issue here.

I got this error:

Fatal error: Call to a member function setFormAction() on a non-object in C:\xampp\htdocs\magento\app\code\local\Evolve\Leads\controllers\IndexController.php on line 13

Here is my code:

IndexController:

public function indexAction()
    
{
        $this
->loadLayout();
        
$this->getLayout()->getBlock('leadsForm')
            ->
setFormActionMage::getUrl('*/*/save') );

        
$this->_initLayoutMessages('customer/session');
        
$this->_initLayoutMessages('core/session');

        
$this->renderLayout();
    
}

leads.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <
leads_index_index  translate="label">
        <
label>Leads Form</label>
        <
reference name="root">
            <
action method="setTemplate"><template>page/1column.phtml</template></action>
        </
reference>
        <
reference name="content">
            <
block type="core/template" name="leadsForm" template="leads/form.phtml" />
        </
reference>
    </
leads_index_index>
</
layout>

And of course, I have the app/design/enterprise/default/templates/leads/form.phtml

Do you have any suggestion?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top