We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Today, we are going to see how to create system.xml, step-by-step.

    Step 1: Create System.xml

    We can do it by creating a system.xml file in the
    app/code/MageMonkeys/HelloWorld/etc/adminhtml/
    directory.

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <system>
            <tab id="magemonkeys" translate="label" sortOrder="10">
                <label>MageMonkeys</label>
            </tab>
            <section id="helloworld" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
                <class>separator-top</class>
                <label>Hello World</label>
                <tab>magemonkeys</tab>
                <resource>MageMonkeys_HelloWorld::helloworld_config</resource>
                <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>General Configuration</label>
                    <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                        <label>Module Enable</label>
                        <source_model>MagentoConfigModelConfigSourceYesno</source_model>
                    </field>
                    <field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                        <label>Display Text</label>
                        <comment>This text will display on the frontend.</comment>
                    </field>
                </group>
            </section>
        </system>
    </config

    Step 2: Set default value

    We can do it by creating a config.xml file in the
    app/code/MageMonkeys/HelloWorld/etc/ directory.

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
        <default>
            <helloworld>
                <general>
                    <enable>1</enable>
                    <display_text>Hello World</display_text>
                </general>
            </helloworld>
        </default>
    </config>

    Step 3: Flush Magento Cache

    php bin/magento cache:clean
    

    Result

    field_5bfb909c5ccae

      Get a Free Quote