1

I'm working on a new extension which has the need for some user defined key-value pairs. In the system config area of the admin panel the user will need to enter several values such as:

"some/relative/path" -> "some external uri"
"some/relative/path" -> "some external uri"
"some/relative/path" -> "some external uri"

In the admin panel I'd like to present the user with two side-by-side text boxes, with validation that requires entries in both boxes to submit.

Is there an existing model that has that functionality?

2
  • 1
    Are you building your own form or using the system.xml? Do you want client or server sided validation? This does sound like a view related task, not something which is to be solved by the choice of a model. Oct 13, 2014 at 13:52
  • I'm looking for a system.xml implementation in the admin panel--validation can be server side. Basically I'm looking for an example of a single system config entry which requires multiple fields.
    – STW
    Oct 13, 2014 at 13:58

1 Answer 1

1
<?xml version="1.0"?>
<config>
    <tabs>
        <something translate="label" module="mname">
            <label>something</label>
            <sort_order>550</sort_order>
        </something>
    </tabs>
    <sections>
        <some translate="label" module="mname">
            <label>first section</label>
            <tab>your tab</tab>
            <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>
            <groups>
                <relative translate="label, comment">
                    <label>first group</label>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <sort_order>1</sort_order>
                    <fields>
                        <path1>
                            <label>first field</label>
                            <comment>description</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>3</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </path1>
                        <path2>
                            <label>second field</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </path2>
                        <path3>
                            <label>third and last field</label>             
                            <frontend_type>password</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </path3>
                    </fields>
                </relative>
            </groups>
        </some>
    </sections>
</config>

this will create keys some/relative/path1, some/relative/path2 and some/relative/path3 with user values in core_config_data.

It can be used elsewhere in the code with :

$configValue = Mage::getStoreConfig('some/relative/path1');

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.