Skip to main content
4 of 4
edited tags
sv3n
  • 11.7k
  • 7
  • 41
  • 73

system.xml dependencies across groups/fieldsets

The system.xml allows us to make the visibility of individual fields dependent on values from other fields. The goto article is of course from Alan Storm: In Depth Magento System Configuration

It looks something like this (I am borrowing his example code here):

Location: app/code/local/Alanstormdotcom/Helloworld/etc/system.xml

<config>
<tabs>
    <helloconfig translate="label" module="helloworld">
        <label>Hello Config</label>
        <sort_order>99999</sort_order>
    </helloconfig>
</tabs>
<sections>
    <helloworld_options translate="label" module="helloworld">
        <label>Hello World Config Options</label>
        <tab>helloconfig</tab>
        <frontend_type>text</frontend_type>
        <sort_order>1000</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
        <groups>
            <notes translate="label">
                <label>Demo Of Config Fields NOTES</label>
                <frontend_type>text</frontend_type>
                <sort_order>1</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <fields>
                    <enabled translate="label">
                        <label>Enabled</label>
                        <frontend_type>select</frontend_type>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </enabled>
                    <hello_note>
                        <label>Message</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>2</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                        <depends>
                            <enabled>1</enabled>
                        </depends>
                    </hello_note>
                </fields>
            </notes>
            <messages translate="label">
                <label>Demo Of Config Fields MESSAGES</label>
                <frontend_type>text</frontend_type>
                <sort_order>1</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <fields>
                    <hello_message>
                        <label>Message</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </hello_message>
                    <hello_time>
                        <label>Time to Say Hello</label>
                        <frontend_type>time</frontend_type>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </hello_time>
                </fields>
            </messages>
        </groups>
    </helloworld_options>
</sections>

Since this seems to only work with fields inside the same group/fieldset (<notes> in this example), I want to know: is there a way to make <hello_message> from the <messages> group dependent on <enabled> from the <notes> group?

jmk
  • 771
  • 1
  • 6
  • 12