简体   繁体   English

致命错误:在Form.php中的非对象上调用成员函数toOptionArray()

[英]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);
}
} 

Refer this link . 请参考此链接

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.

相关问题 Symfony2日期表单类型:致命错误:在非对象上调用成员函数setLenient() - Symfony2 date form type: Fatal error: Call to a member function setLenient() on a non-object Zend \\ Form:在Zend / Form / Fieldset.php中的非对象上调用成员函数insert() - Zend\Form: Call to a member function insert() on a non-object in Zend/Form/Fieldset.php 错误:使用Symfony组件形式的ChoiceType调用非对象上的成员函数 - Error: Call to a member function on a non-object using ChoiceType of Symfony component form 我不断收到致命错误:使用sqli查询在非对象发布上调用成员函数bind_param() - I keep getting Fatal error: Call to a member function bind_param() on a non-object posting with sqli query 在非对象中调用成员函数bind() - Call to a member function bind() on a non-object in 在非对象错误symfony2上调用成员函数 - Call to a member function on a non-object error symfony2 在第82行上,在profile.php中的非对象上调用成员函数query() - Call to a member function query() on a non-object in profile.php on line 82 在非对象上调用成员函数getClientOriginalExtension(),即使'file'=> true - Call to a member function getClientOriginalExtension() on a non-object even with 'file' => true 在非对象 - 授权上调用成员函数allow() - Call to a member function allow() on a non-object - authorization Symfony 2异常:使用表单事件时,在非对象上调用成员函数 - Symfony 2 Exception: Call to a member function on a non object when using Form Events
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM