1

I am trying to add some config settings under Magento configuration and I had success with my module and a bit of XML code in system.xml but the problem is it is displaying only one field though I have defined four fields - it's just showing the last one, the sort_order for each input is defined as well.

Here is my system.xml file.

<?xml version="1.0"?>
<config>
    <tabs>
        <mgconf translate="label">
            <label>Magegurus SMTP E-Mail</label>
            <sort_order>999</sort_order>
        </mgconf>
    </tabs>
    <sections>
        <mgsmtp translate="label" module="adminhtml">
            <label>Magegurus SMTP E-Mail</label>
            <tab>mgconf</tab>
            <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>
            <groups>
                <general translate="label comment">
                    <label>Settings</label>
                    <sort_order>50</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <text_field translate="label comment">
                            <label>Host Name</label>
                            <comment>Your SMTP host name here.</comment>
                            <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>
                        </text_field>
                        <text_field translate="label comment">
                            <label>Port</label>
                            <comment>Your SMTP port here.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </text_field>

                        <text_field translate="label comment">
                            <label>Username</label>
                            <comment>Your SMTP username here.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </text_field>

                        <text_field translate="label comment">
                            <label>Password</label>
                            <comment>Your SMTP password here.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>40</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </text_field>
                    </fields>
                </general>
            </groups>
        </mgsmtp>
    </sections>
</config>

The config is only showing last fields the Password. Any idea what is wrong?

1 Answer 1

2

This happens because all the fields have the tag text_field. Name them differently and they should appear. I mean something like:

                  <fields>
                    <text_field translate="label comment">
                        <label>Host Name</label>
                        <comment>Your SMTP host name here.</comment>
                        <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>
                    </text_field>
                    <text_field2 translate="label comment">
                        <label>Port</label>
                        <comment>Your SMTP port here.</comment>
                        <frontend_type>text</frontend_type>
                        <sort_order>20</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </text_field2>
                    ....
                 </fields>
4
  • Thanks .. i thought text_field is for displaying text box.
    – Ravi Soni
    May 24, 2013 at 13:09
  • 1
    no. In your case 'text_field' is the identifier of the field. You will later get the value like this: Mage::getStoreConfig('mgsmtp/general/text_field'). The type of the input is given by the tag <frontend_type>.
    – Marius
    May 24, 2013 at 13:17
  • Hey..Thanks for your explanation. Any idea on how can i call some controller via ajax using system config.
    – Ravi Soni
    May 24, 2013 at 13:24
  • 2
    I'm not sure I understand what you mean. Anyway, I don't think is related to this question. Post an other question with some additional details about your issue.
    – Marius
    May 24, 2013 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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