错误:
Fatal error: Call to a member function setGuestName() on a non-object in IndexController.php
{main}( ) - index.php
Mage::run( ) - index.php(line:87)
Mage_Core_Model_App->run( ) - Mage.php(line:684)
Mage_Core_Controller_Varien_Front->dispatch( ) - App.php(line:354)
Mage_Core_Controller_Varien_Router_Standard->match( ) - Front.php(line:172)
Mage_Core_Controller_Varien_Action->dispatch( ) - Standard.php(line:250)
Test_Contacts_IndexController->postAction( ) - Action.php(line:418)
我的代码:
$model = Mage::getModel('contacts/contacts');
$model->setGuestName( trim($post['name']) );
$model->setGuestEmail(trim($post['email']));
$model->setGuestTelephone(trim($post['telephone']));
$model->setGuestComments(trim($post['comment']));
$model->setGuestAttachment(trim($post['attachment']));
$model->save( );
我不确定你的框架是如何工作的,但不应该是 $_POST['']
而不是$POST['']
?
是否有
可能对联系人/联系人的权限设置不正确?您确定联系人/联系人是正确的位置吗?
请使用以下代码确认模型对象正确加载:
$model = Mage::getModel('contacts/contacts');
echo get_class($model);
die;
如果正确加载,这将打印您的模型类名。否则,您需要检查配置 xml。
如果要将联系表单数据保存在数据库中。这是一个不错的扩展:http://www.magentocommerce.com/magento-connect/ultimate-contact-us-page-1.html
希望这个帮助!!