gpt4 book ai didi

Magento 模块 system.xml 复选框不会保存

转载 作者:行者123 更新时间:2023-12-04 12:12:37 24 4
gpt4 key购买 nike

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

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

config.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>

最佳答案

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

基本上问题是magento只将输入参数'value'保存在db中,而在输入复选框中,重要的值是'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>

关于Magento 模块 system.xml 复选框不会保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7206746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com