错误:
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( );
答案 0 :(得分:1)
我不确定你的框架是如何工作的,但不应该
$_POST['']
代替$POST['']
?
答案 1 :(得分:0)
是否可能在联系人/联系人上错误设置权限?您确定联系人/联系人是正确的位置吗?
答案 2 :(得分:0)
请使用以下代码确认您的模型对象正确加载:
$model = Mage::getModel('contacts/contacts');
echo get_class($model);
die;
这将打印模型类名称如果正确加载。否则你需要检查config xml。
如果要在数据库中保存联系表单数据。这是一个很好的扩展: http://www.magentocommerce.com/magento-connect/ultimate-contact-us-page-1.html
希望这有帮助!!