2

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

3
  • 2
    U can use <comment>. What is point of giving label as value? Commented May 12, 2017 at 9:58
  • What you want to show as text only? Commented May 12, 2017 at 10:48
  • When I use <comment> im getting an inputfield. I want display a small note so that users can read that before they submit a file Commented May 12, 2017 at 11:02

3 Answers 3

6

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

1
  • I cant upvote because I dont have 15 rep yet Commented May 15, 2017 at 8:44
3

I also wanted to add custom text in store configuration and found below simple way to add custom text:

<field id="test" translate="label" type="label" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>NOTE: </label>
    <comment>Your Custom TEXT Here...</comment>
</field>                

Hope will be helpful for someone.

0

system.xml

<field id="test" type="label">
    <label>Test</label>
</field>

in config.xml define it's value

<?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>
        <groupname>
            <settings>
                <test>values</test>
            </settings>
        </groupname>
    </default>
</config>

Use CDATA[] if neeed

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.