Magento 2 System.xml – How to Add Text in system.xml

magento2magento2.2system.xml

Is it possible to have plain text next to the label in system config instead of an input field, something like:

<field>
    <label>Hey you</label>
    <plainText>Lorem ipsum...</plainText>
</field>

The closest I can get is using a label, but thats looks bad when I have more than 4 words in it. This is what it should look like:

Plain text in system config

Best Answer

system.xml

<field id="test" translate="label" type="label" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
    <label>Hey you!</label>
</field>

config.xml

app/code/Vendor/Module/etc/config.xml

<?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>
        <section>
            <group>
                <test>Your values here</test>
            </group>
        </section>
    </default>
</config>

OUTPUT:

enter image description here

Related Topic