3

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.

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
Matteo
  • 1,107
  • 2
  • 27
  • 47
  • This is definitely functionality that can be handled in Magento. You may want to read up on how to setup configuration options for your module. After you've done that, feel free to ask specific questions if you hit walls. – Joe Mastey Jul 13 '11 at 15:05
  • Pretty vague, it is something that I've already done, and currently I'm still looking links from google about, that is why I've asked here, I can't find a solution to that. – Matteo Jul 13 '11 at 15:23

2 Answers2

5

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.

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
  • 1
    Side note: if you need show/hide block, etc. depending on config value, in your layout update file you should use ifconfig attribute: ``. – Dmytro Zavalkin Jul 13 '11 at 21:09
0

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>
Community
  • 1
  • 1
cobhimself
  • 11
  • 1
  • 4