I'm trying to build my own Request Catalog Form in Magento, heavily based on the Contacts module that comes out of the box. I've set up my XML files:
- ./app/etc/modules/RequestCatalog_RequestCatalog.xml
- ./design/frontend/default/{theme}/layout/requestcatalog.xml
- ./code/local/{namespace}/{module}/etc/config.xml
In my config.xml, I set my frontname to 'requestcatalog' and told it to use my module's controller. However, when I visit http://app.com/requestcatalog I receive the error:
Fatal error: Call to a member function setFormAction() on a non-object in /path/to/root/public_html/app/code/local/RequestCatalog/RequestCatalog/controllers/IndexController.php on line 55
Line 55 of IndexController.php looks like:
$this->getLayout()->getBlock('requestcatalog')->setFormAction( Mage::getUrl('*/*/post') );
I have my block named 'requestcatalog' defined in my layout XML.
I've searched SO and found a user w/ the same problem, however no solution was provided: http://stackoverflow.com/questions/1098518/magento-custom-module-fatal-error-call-to-a-member-function-setformaction
My requestcatalog.xml:
<layout version="0.1.0">
<default>
<reference name="footer_links">
<action method="addLink" translate="label title" module="requestcatalog" ifconfig="requestcatalog/requestcatalog/enabled"><label>Request a Catalog</label><url>requestcatalog</url><title>Request a Catalog</title><prepare>true</prepare></action>
</reference>
</default>
<requestcatalog_index_index>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<action method="setHeaderTitle" translate="title" module="requestcatalog"><title>Request a Catalog</title></action>
</reference>
<reference name="content">
<block type="core/template" name="requestcatalog" template="requestcatalog/form.phtml"/>
</reference>
</requestcatalog_index_index>
My IndexAction():
public function indexAction()
{
$this->loadLayout();
$this->getLayout()->getBlock('requestcatalog')
->setFormAction( Mage::getUrl('*/*/post') );
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
$this->renderLayout();
}