0

Recently I tried to extend the contact form on our website. I wanted to add a drop-down with some possible subjects the user could select. To do this I created a new module MyCompany/Contacts in the local codepool. In this module I defined a new block for the frontend model where the subjects can be configured.

But now I can no longer access the contacts settings page. I get the following error:

Invalid config field backend model: contacts/system_config_backend_links

Trace:
#0 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(328): Mage::throwException('Invalid config ...')
#1 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(229): Mage_Adminhtml_Block_System_Config_Form->initFields(Object(Varien_Data_Form_Element_Fieldset), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#2 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(164): Mage_Adminhtml_Block_System_Config_Form->_initGroup(Object(Varien_Data_Form), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#3 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php(92): Mage_Adminhtml_Block_System_Config_Form->initForm()
#4 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php(107): Mage_Adminhtml_Block_System_Config_Edit->initForm()
#5 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_System_ConfigController->editAction()
#6 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('edit')
#7 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /home/users/webxuftp/test.webshopdemeesternv.be/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#9 /home/users/webxuftp/test.webshopdemeesternv.be/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#10 /home/users/webxuftp/test.webshopdemeesternv.be/index.php(83): Mage::run('', 'store')
#11 {main}

Apparently now it can't find the models from the original Mage/Contacts module (in partiucular: Mage_Contacts_Model_System_Config_Backend_Links). Does this have anything to do with the system.xml or config.xml files from my MyCompany/Contacts module?

I will include them here just in case: config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <DeMeester_Contacts>
            <version>1.0.0</version>
        </DeMeester_Contacts>
    </modules>
    <global>
        <helpers>
            <contacts>
                <rewrite>
                    <data>DeMeester_Contacts_Helper_Data</data>
                </rewrite>
            </contacts>
        </helpers>
        <blocks>
            <contacts>
                <class>DeMeester_Contacts_Block</class>
            </contacts>
        </blocks>
    </global>
    <frontend>
        <routers>
            <contacts>
                <args>
                    <modules>
                        <DeMeester_Contacts before="Mage_Contacts">DeMeester_Contacts</DeMeester_Contacts>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>

system.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <sections>
        <trans_email>
            <groups>
                <ident_emails translate="comment">
                    <label>Custom Support Emails</label>
                    <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>
                        <emails translate="comment">
                            <label>Emails</label>
                            <frontend_model>contacts/system_config_form_field_customemail</frontend_model>
                            <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
                            <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>
                        </emails>
                    </fields>
                </ident_emails>
            </groups>
        </trans_email>
    </sections>
</config>

Thanks in advance!

0

If you want to extend the contact system configuration field so you need override the system.xml add this code between <section></section> like that:

<contacts translate="label" module="contacts">
        <label>Contacts</label>
        <tab>general</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>1</show_in_store>
        <groups>
            <contacts translate="label">
                <label>Contact Us</label>
                <frontend_type>text</frontend_type>
                <sort_order>10</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <fields>
                    <test translate="label">
                        <label>Enable Contact Us</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_yesno</source_model>
                        <backend_model>contacts/system_config_backend_links</backend_model>
                        <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>
                    </test>
                </fields>
            </contacts>
        </groups>
    </contacts>
0

The problem here is that you are using the same nodes for your module as Magento uses for it's standard contacts module.

If you change your local modules xml then you should have no issues.

Wrong

    <blocks>
        <contacts>
            <class>DeMeester_Contacts_Block</class>
        </contacts>
    </blocks>

Updated

    <blocks>
        <demeester_contacts>
            <class>DeMeester_Contacts_Block</class>
        </demeester_contacts>
    </blocks>

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.