1

i made a custom module and in system.xml i have defined an image field like so:

<banner_image translate="label" module="my_theme">
    <label>Banner Image</label>
    <frontend_type>image</frontend_type>
    <backend_model>adminhtml/system_config_backend_image</backend_model>
    <upload_dir config="system/filesystem/media" scope_info="1">theme</upload_dir>
    <base_url type="media" scope_info="1">theme</base_url>
    <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>
    <comment>Press "Save Config" (upper right button) to upload the picture file</comment>
</banner_image>

the problem is that when i press "Save Config" to upload the file i get the following error in the log:

2015-05-05T14:24:25+00:00 ERR (3): Notice: Undefined index: groups  in /chroot/home/mysite/html/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/File.php on line 51

and no image appears (using Magento 1.9.1.0)

any help will be appreciated

thanks

2

I am afraid with the information that you provided I am unable to point out the exactly the cause of you issue. The reason for this is that your issue does not live in the snippet of xml that you provided but rather a little earlier in the xml file. The best help that I can provide is show a full working example and hope that this points you in the right direction.

I believe that your issues revolves the missing/incorrect groups section further up in your system.xml file. The correct xpath that you are looking for should look something along the lines of:

config/sections/[module section]/groups/[module subsection]/fields

Below I have attached a working copy of the system.xml that I hope will assist you further.

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <stackexchange translate="label" module="stackexchange_imageupload">
            <label>Stack Exchange</label>
            <sort_order>150</sort_order>
        </stackexchange>
    </tabs>
    <sections>
        <stackexchange_imageupload translate="title" module="stackexchange_imageupload">
            <label>Stack Exchange Image Upload</label>
            <tab>stackexchange</tab>
            <frontend_type>text</frontend_type>
            <sort_order>100</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
            <groups>
                <general translate="label">
                    <label>General</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>5</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>0</show_in_store>
                    <fields>
                        <banner_image translate="label" module="stackexchange_imageupload">
                            <label>Banner Image</label>
                            <frontend_type>image</frontend_type>
                            <backend_model>adminhtml/system_config_backend_image</backend_model>
                            <upload_dir config="system/filesystem/media" scope_info="1">theme</upload_dir>
                            <base_url type="media" scope_info="1">theme</base_url>
                            <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>
                            <comment>Press "Save Config" (upper right button) to upload the picture file</comment>
                        </banner_image>
                    </fields>
                </general>
            </groups>
        </stackexchange_imageupload>
    </sections>
</config>
  • I got a similar problem in Megamenu module, due to a <depends> field. If the image field is not shown, Magento expects to receive it anyway, and throws the same error. I have had to remove the <depends> node and add a <comment> instead. – Ricardo Martins Feb 15 '17 at 14:02
0
                    <fields>
                        <banner_image translate="label" module="stackexchange_imageupload">
                            <label>Banner Image</label>
                            <frontend_type>image</frontend_type>
                            <backend_model>adminhtml/system_config_backend_image</backend_model>
                            <upload_dir config="system/filesystem/media" scope_info="1">theme</upload_dir>
                            <base_url type="media" scope_info="1">theme</base_url>
                            <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>
                            <comment>Press "Save Config" (upper right button) to upload the picture file</comment>
                        </banner_image>
                    </fields>

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.