Skip to content

Struggling to render the UI component #8

@tylers-username

Description

@tylers-username

I have copied the Select example into view/adminhtml/ui_component/select2.xml. In my layout.xml I have added:

<?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">
        <item name="options" xsi:type="object">Magento\Customer\Model\Customer\Attribute\Source\Group</item>
        <item name="js_config" xsi:type="array">
            <item name="dataType" xsi:type="string">text</item>
            <item name="label" translate="true" xsi:type="string">Customer Group</item>
            <item name="formElement" xsi:type="string">select</item>
            <item name="source" xsi:type="string">Group</item>
            <item name="sortOrder" xsi:type="number">40</item>
            <item name="dataScope" xsi:type="string">group_id</item>
            <item name="validation" xsi:type="array">
                <item name="required-entry" xsi:type="boolean">true</item>
            </item>
            <item name="elementTmpl" xsi:type="string">Monin_UiComponentSelect2/form/element/select2</item>
            <item name="component" xsi:type="string">Monin_UiComponentSelect2/js/form/element/select2</item>
            <item name="select2" xsi:type="array">
                <item name="maximumSelectionLength" xsi:type="string">1</item>
                <item name="tags" xsi:type="string">true</item>
            </item>
        </item>
    </argument>
</form>

In my layout file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="left">
            <uiComponent name="select2" />
        </referenceContainer>
    </body>
</page>

The output I get is:

Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Call to a member function getRequestFieldName() on null in /app/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions