[英]Fatal error: Call to a member function toOptionArray() on a non-object in Form.php
i get this error for my payment interface when config payment methods 配置付款方式时,我的付款界面出现此错误
'USD', 'label'=>Mage::helper('adminhtml')->__('USD')), array('value' => 'EUR', 'label'=>Mage::helper('adminhtml')->__('EUR')), ); } } ?>
Fatal error: Call to a member function toOptionArray() on a non-object in C:\xampp\htdocs\pjsnorge2\app\code\core\Mage\Adminhtml\Block\System\Config\Form.php on line 399
and in the processingCurrency.php 并在processingCurrency.php中
class Gspay_Redirect_Model_ProcessingCurrency
{
public function toOptionArray()
{
return array(
array('value' => 'USD', 'label'=>Mage::helper('adminhtml')->__('USD')),
array('value' => 'EUR', 'label'=>Mage::helper('adminhtml')->__('EUR')),
);
}
}
thanks for your help 谢谢你的帮助
To solve the above error. 解决以上错误。 Please open the above path file. 请打开上面的路径文件。
if ($e->source_model) {
$sourceModel = Mage::getSingleton((string)$e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
}
Replace above code with below: 将上面的代码替换为下面的代码:
if ($e->source_model) {
$sourceModel = Mage::getSingleton((string)$e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
if(is_object($sourceModel)){
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
} else {
Mage::log($e->source_model);
}
}
Change following code in this file app/code/core/Mage/Adminhtml/Block/System/Config/Form.php that answer by @ILLA at above and it completely working. 在此文件app / code / core / Mage / Adminhtml / Block / System / Config / Form.php中更改以下由@ILLA回答的代码,它可以正常工作。
if ($e->source_model)
{
$sourceModel = Mage::getSingleton((string)$e->source_model);
if ($sourceModel instanceof Varien_Object)
{
$sourceModel->setPath($path);
}
if(is_object($sourceModel))
{
if (method_exists($sourceModel, "toOptionArray"))
{
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
}
}
else
{
Mage::log($e->source_model);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.