3

I need to display a non-editable field in Magento 2.1 Admin grid. so i tried to use :

        <field name="type">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" translate="true" xsi:type="string">type</item>
                <item name="formElement" xsi:type="string">label</item>
                <item name="source" xsi:type="string">Order</item>
                <item name="sortOrder" xsi:type="number">110</item>
                <item name="dataScope" xsi:type="string">type</item>
                </item>
            </item>
        </argument>
    </field>

but i'm getting the following error:

a:4:{i:0;s:94:"The requested component ("label") is not found. Before using, you must add the implementation.";i:1;s:7394:"#0 /var/www/magento /vendor/magento/module-ui/Model/Manager.php(207): Magento\Framework\View\Element\UiComponent\Config\Provider\Component\Definition->getComponentData('label')

note: i'm aware about :

<item name="disabled" xsi:type="boolean">true</item>

but this will just show an inout field as disabled , where i want to show a plain text

any advice?

reference: https://github.com/magento/magento2/blob/2335247d4ae2dc1e0728ee73022b0a244ccd7f4c/lib/internal/Magento/Framework/Data/Form/Element/Label.php

1
  • did you managed to find a solution for this? Commented Jun 13, 2019 at 13:51

1 Answer 1

2

Leave formElement as input and add text elementTmpl <item name="elementTmpl" xsi:type="string">ui/form/element/text</item> For that case it'll be something like this

<field name="type">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="dataType" xsi:type="string">text</item>
            <item name="label" translate="true" xsi:type="string">type</item>
            <item name="formElement" xsi:type="string">input</item>
            <item name="source" xsi:type="string">Order</item>
            <item name="sortOrder" xsi:type="number">110</item>
            <item name="elementTmpl" xsi:type="string">ui/form/element/text</item>
            <item name="dataScope" xsi:type="string">type</item>
            </item>
        </item>
    </argument>
</field>

Know it's a bit too late answer but hope someone will find it usefull

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.