문제

사용자 정의 필드 값이있는 시스템 구성 섹션을 만들려고합니다

이것은 내 코드입니다 :

system.xml

<?xml version="1.0"?>
<config>
    <tabs>
        <macerierconf translate="label">
            <label>Macerier</label>
            <sort_order>150</sort_order>
        </macerierconf>
    </tabs>
    <sections>
        <tab1 translate="label" module="adminhtml">
            <label>Settings</label>
            <tab>macerierconf</tab>
            <sort_order>100</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <smssending translate="label comment">
                    <label>test label</label>
                    <sort_order>60</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <device translate="label comment">
                            <label>Device</label>
                            <frontend_type>select</frontend_type>
                            <source_model>macerier_test/system_config_source_dropdown_values</source_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </device>
                    </fields>
                </smssending>
            </groups>
        </tab1>
    </sections>
</config>
.

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Macerier_TEST>
            <version>0.1.0</version>
        </Macerier_TEST>
    </modules>
    <global>
        <models>
            <macerier_test>
                <class>Macerier_TEST_Model</class>
            </macerier_test>
        </models>
    </global>
</config>
.

그런 다음 Macerier\TEST\Model\System\Config\Source\Dropdown\Values.php에서 다음과 같습니다.

<?php

class Macerier_TEST_Model_System_Config_Source_Dropdown_Values
{
    public function toOptionArray()
    {
        return array(
            array(
                'value' => 'key1',
                'label' => 'Value 1',
            ),
            array(
                'value' => 'key2',
                'label' => 'Value 2',
            ),
        );
    }
}
.

이 오류가 발생했습니다 :

PHP 치명적인 오류 : /home/user/public_html/magento/App/CoDE/Core/Mage/Adminhtml/block/system/config/form.php의 객체가 아닌 멤버 함수 tooptionArray ()를 호출합니다.라인 463

사용자 정의 원본 모델이없는 모듈이 작동하지 않아서 뭔가 잘못하고 있습니다.

도움이 되었습니까?

해결책

드롭 다운은 소스 모델

을 가져올 수 없습니다.

EneracoDiceCodeTagcode가 오류를 보여주는 이유

는 모델 접두사를 정의하지 않았을 수 있습니다.

코드 macerier_test/system_config_source_dropdown_values의 경우.모델 접두사

입니다

그래서 macerier_test에서 모델 접두사를 정의합니다

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Macerier_TEST>
            <version>0.1.0</version>
        </Macerier_TEST>
    </modules>
    <!-- add this -->
    <global>
    <models>
        <macerier_test> <!-- call as model prefix identifier -->
            <class>Macerier_TEST_Model</class>
        </macerier_test>
    </models>
    </global>

</config>
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top