作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 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 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/
我是一名优秀的程序员,十分优秀!