Magento 1.9 – Fix 404 Error on Save in Custom Module Admin Panel

404adminhtmlgridmagento-1.9

In /magento1/app/code/local/Maddyboy/Instagramapi/etc/config.xml:

<adminhtml>
  <acl>
    <resources>
      <admin>
        <children>
          <system>
            <children>
              <config>
                <children>
                  <instagramapi translate="title" module="instagramapi">
                    <title>Instagram Slider</title>
                  </instagramapi>
                </children>
              </config>
            </children>
          </system>
        </children>
      </admin>
    </resources>
  </acl>
  <layout>
    <updates>
      <instagramapi>
        <file>instagramapi.xml</file>
      </instagramapi>
    </updates>
  </layout>
</adminhtml>  

In /magento1/app/code/local/Maddyboy/Instagramapi/etc/system.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <instagramapi translate="label" module="instagramapi">
            <label>Instagram Slider</label>
            <sort_order>1</sort_order>
        </instagramapi>
    </tabs>

    <sections>
        <instagramapi translate="label" module="instagramapi">
            <label>Api Settings</label>
            <tab>instagramapi</tab>
            <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>
            <groups>
                <section_one translate="label">
                    <label>Section One</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>
                        <custom_field_one>
                            <label>Custom Text Field</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>
                            <comment>Example of text field.</comment>         
                        </custom_field_one>
                    </fields>
                </section_one>
            </groups>                
        </instagramapi>
    </sections>
</config>

when I enter some dummy data and click on save I got a 404 error.

URL after save: http://127.0.0.1/magento1/index.php/admin/system_config/save/key/3537cf9ef9d3161eb483f8251284d9f9/section/instagramapi_options/
error

errorshot

Best Answer

in your config.xml in (or adminhtml.xml) you should have

<acl>
    <resources>
        <all>
            <title>Allow Everything</title>
        </all>
        <admin>
            <children>
                <system>
                    <children>
                        <config>
                            <children>
                                <instagramapi translate="title" module="instagramapi">
                                    <title>Instagram Slider</title>
                                </instagramapi>
                            </children>
                        </config>
                    </children>
                </system>
            </children>
        </admin>
    </resources>
</acl>

Then in your system.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <instagramapi_tab translate="label" module="instagramapi">
            <label>Instagram Slider</label>
            <sort_order>1</sort_order>
        </instagramapi_tab>
    </tabs>

    <sections>
        <instagramapi translate="label" module="instagramapi">
            <label>Api Settings</label>
            <tab>instagramapi_tab</tab>
            <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>
            <groups>
                <section_one translate="label">
                    <label>Section One</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>
                        <custom_field_one>
                            <label>Custom Text Field</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>
                            <comment>Example of text field.</comment>         
                        </custom_field_one>
                    </fields>
                </section_one>
            </groups>                
        </instagramapi>
    </sections>
</config>

Be sure to log off and on again after each change to the acls. If needed, flush the magento cache ("Flush Magento Cache")

Related Topic