4

I have a field called "active" in "group1" that should only be shown if the value of the field "username" in "group0" has been entered.

I have the following code at the moment:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <sections>
        <carriers>
            <groups>
                <group0 translate="label" module="mymodule">
                    <label>Settings</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>98</sort_order>
                    <show_in_default>1</show_in_default>                 <!-- show in default is on -->
                    <show_in_website>1</show_in_website>                <!-- show in website is on -->
                    <show_in_store>1</show_in_store>                    <!-- show in store is on -->
                    <fields>
                        <username translate="label">
                            <label>Username</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>103</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </username>
                    </fields>
                </group0>
                <group1 translate="label" module="mymodule">
                    <label>Groupe 1</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>99</sort_order>
                    <show_in_default>1</show_in_default>                 <!-- show in default is on -->
                    <show_in_website>1</show_in_website>                <!-- show in website is on -->
                    <show_in_store>1</show_in_store>                    <!-- show in store is on -->
                    <fields>
                        <active translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>          <!-- select options model -->
                            <sort_order>101</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </active>
                        <title translate="label">
                            <label>Carrier Title</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>103</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends>
                                <active>1</active>
                            </depends>
                        </title>
                    </fields>
                </group1>
            </groups>
        </carriers>
    </sections>
</config>
  • don't drop your code, what is your question? explain it – Nickool Apr 13 '15 at 0:34
0

After consulting the appropriate core file a cross group/fieldset <depends> looks like this:

<!-- … -->
<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>
    <depends>
        <enabled>
            <fieldset>notes</fieldset>
            <value>1</value>
        </enabled>
    </depends>
</hello_message>
<!-- … -->
1

As far as I know you can pass in a full config path when dealing with the depends node.

<depends>
    <config>your/full/path</config>
</depends>

This will then allow you to depend on items outside of the current group.

  • It doesn't work. At least not if config field with full path is inserted in the database but not defined in settings layout. Magento 1.9.2.4 – Marek Jun 23 '17 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.