I try to add text item to adminhtml UI component as described in docs:
<?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <argument name="data" xsi:type="array">...</argument> <settings>...</settings> <dataSource ...>...</dataSource> <fieldset name="..._form"> ... <text name="text_example" template="ui/form/field"> <settings> <label translate="true">Text Field Example</label> <visible>true</visible> <disabled>false</disabled> <elementTmpl>ui/form/element/text</elementTmpl> <value>The text value example</value> </settings> </text> </fieldset> </form> I have an error in browser:
1 exception(s): Exception #0 (Magento\Framework\Exception\LocalizedException): The XML in file "/.../view/adminhtml/ui_component/..._form.xml" is invalid: Element 'value': This element is not expected. Line: 63 Verify the XML and try again. <pre>#1 Magento\Ui\Config\Reader->read() called at [vendor/magento/module-ui/Config/Data.php:102] #2 Magento\Ui\Config\Data->initData() called at [vendor/magento/module-ui/Config/Data.php:136] #3 Magento\Ui\Config\Data->get() called at [vendor/magento/framework/View/Layout/Reader/UiComponent.php:100] #4 Magento\Framework\View\Layout\Reader\UiComponent->interpret() called at [vendor/magento/framework/View/Layout/ReaderPool.php:105] ... I've checked text.xsd and ui_component.xsd and I don't see value attribute is defined there.
What is the right way to add text item to UI form?
These are the text items based on @Marius (first one) and @Shailesh Katarmal (second one) answers below:
Marius code should be slightly edited:
<text template="ui/form/element/text"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="inputName" xsi:type="string">text_example</item> <item name="value" xsi:type="string">Lorem ipsum ...</item> </item> </argument> </text> but Shailesh Katarmal code can be used as is.
Thanks, guys!
