7

在 Magento v1.5.0.1 中,有人知道使用<frontend_type>checkbox</frontend_type>system.xml 中的配置指令的问题吗?即使在只有一个配置变量且没有块/模型的最简单的哑模块中,如果我选中该框并点击“保存”,它也会重新加载页面并取消选中该复选框,即使它表示配置已成功保存。我搜索了代码,它只在几个地方使用。大多数时候,人们使用<frontend_type>select</frontend_type>with <source_model>adminhtml/system_config_source_yesno</source_model>。这行得通,但为什么复选框也不起作用?还是我误解了 Magento 复选框应该如何工作?

如果有帮助,这是我的文件。在这种情况下,我还添加了一个文本字段变量。如果我输入文本并点击保存,那确实会保存,但复选框不会:

配置.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Brian_Stupid>
            <version>0.1.0</version>
        </Brian_Stupid>
    </modules>
    <adminhtml>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <stupid translate="title">
                                            <title>Stupid Crap</title>
                                        </stupid>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>
    </adminhtml>
</config>

系统.xml:

<?xml version="1.0"?>
<config>
    <sections>
        <stupid translate="label">
            <label>Stupid Test</label>
            <tab>catalog</tab>
            <frontend_type>text</frontend_type>
            <sort_order>998</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <debug translate="label">
                    <label>Debugging</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>5</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <debugmode translate="label">
                            <label>Debug Mode Enable</label>
                            <comment>If enabled, does not alter database. Prints debug messages and dies</comment>
                            <frontend_type>checkbox</frontend_type>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </debugmode>
                        <texttest translate="label">
                            <label>Text Test</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </texttest>
                    </fields>
                </debug>
            </groups>
        </stupid>
    </sections>
</config>
4

2 回答 2

6

当我面临类似情况时,我向您发布了我的解决方案

基本上问题是magento只在db中保存输入参数'value',而在输入复选框中,重要的值是'Checked'。

我尝试放置一些js,当复选框更改时根据此设置输入值并且当页面加载相反时......这不起作用。

替代解决方案:使用下拉菜单

 <debugmode translate="label">
                        <label>Debug Mode Enable</label>
                        <comment>If enabled, does not alter database. Prints debug messages and dies</comment>
                        <frontend_type>select</frontend_type>                                                                     
                        <source_model>adminhtml/system_config_source_yesno</source_model>     
                        <sort_order>10</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </debugmode>
于 2012-03-02T17:10:40.320 回答
0

我花了一些时间来获得解决方案,但除了一个之外没有任何解决方案。

看看 Mage-Folder 中的 PayPal 模块。那是唯一使用 Checkboxed 的模块,但它们的设置方式相当困难。

我想这就是为什么每个人都使用带有 yesno 或 enableisable 源的 select 的原因。

于 2011-08-26T19:11:40.483 回答