1

I am trying to create a ui-select element using ui-component form, for fullfil my requirement in admin section.

I have written code as below:

<field name="vendor_id">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">[...]\[...]\Model\Source\Vendor</item>
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">Assign to Vendor</item>
                <item name="componentType" xsi:type="string">field</item>
                <item name="formElement" xsi:type="string">select</item>
                <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
                <item name="elementTmpl" xsi:type="string">ui/grid/filters/elements/ui-select</item>
                <item name="filterOptions" xsi:type="boolean" >true</item>
                <item name="showCheckbox" xsi:type="boolean">false</item>
                <item name="chipsEnabled" xsi:type="boolean" >false</item>
                <item name="disableLabel" xsi:type="boolean">true</item>
                <item name="multiple" xsi:type="boolean" >false</item>
                <item name="listens" xsi:type="array">
                    <item name="newOption" xsi:type="string">toggleOptionSelected</item>
                </item>
                <item name="source" xsi:type="string">event_info</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>  
            </item>
        </argument>
</field>

And the result of the above code is shown below with marked issue: enter image description here

Issues are:

1) Two label as "Assign to vendor" is incorrect

2) Select box width is so small may be due to second label

3) I have made showCheckbox to false so checkbox should not be there.

4) Filter/search is happen on click on search icon or press enter but not by enter key for search.

Can Anyone suggest what I should add to the above code for fullfil my requirements and what wrong I am doing.

I have looked into many post like below but not resolved my issue.

UiComponent Ui Element Ui-select Not Properly Working

How to properly populate ui-select component

Magento2 file reference for the component

Please note my magento version on which I am working is magento 2.0.15.

Please let me know in case of any query.

Thank you.

1

Maybe try to make it simple like:

<field name="vendor_id">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">[...]\[...]\Model\Source\Vendor</item>
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">Assign to Vendor</item>
                <item name="formElement" xsi:type="string">select</item>
                <item name="dataType" xsi:type="string">text</item>
                <item name="source" xsi:type="string">event_info</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>  
            </item>
        </argument>
</field>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.