Custom module conditional configuration optons

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 22:41:34

问题


I would like to programmatically enable or disable specific options for a custom module on the administration panel depending on the status of a select. For example, if I had a Yes/No select something like

do you want to handle stuffs? < select yes/no >

and if stuffs == yes, then a number of other configuration fields would be enabled/visible. If stuffs != yes then those fields would be disabled/invisible.

Is that possible to do programmatically via system.xml/some-other-means, or it is a sci-fi dream?

Thanks for any help.


回答1:


Yes, this is possible. You're interested in the <depends> tag in system.xml. You can read up about it here (self link). The general idea is you can make the appearance of a field depend on another field containing a specific value.




回答2:


I'm using Magento EE 1.9.1.1 and, when using <depends> within a widget, I had to provide a <value> tag that encapsulates the value for the dependency. Just a heads up for anyone who is interested in adding dependencies for their widgets.

You can view my question that covers the issue I was having without the <value> tag.

The final dependency xml path looked like this:

<depends>
    <group_type>
        <value>value to match here</value>
    </group_type>
</depends>


来源:https://stackoverflow.com/questions/6679348/custom-module-conditional-configuration-optons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!