开发者

Custom module conditional configuration optons

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 someth开发者_开发百科ing 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.


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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜