0

I am try to add a search bar to the product custom dropdown attribute. I am able to add it using xml and data is also getting saved, but after loading the product again, it is not showing in admin.

Can some please help

I am following this link as well

Magento 2 Add select-box with search/filter option

Here is my xml code

<field name="xxnmi_project">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">XYZ\ImportProjectData\Model\Attribute\Source\Project</item>
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Project</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="dataScope" xsi:type="string">xxnmi_project</item>
                    <item name="filterOptions" xsi:type="boolean">true</item>
                    <item name="showCheckbox" xsi:type="boolean">true</item>
                    <item name="chipsEnabled" xsi:type="boolean">false</item>
                    <item name="disableLabel" xsi:type="boolean">false</item>
                    <item name="multiple" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">70</item>
                    <item name="listens" xsi:type="array">
                        <item name="newOption" xsi:type="string">toggleOptionSelected</item>
                    </item>
                    <item name="required" xsi:type="boolean">false</item>
                    <item name="source" xsi:type="string">conditions</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">false</item>
                    </item>
                </item>
            </argument>
        </field>

enter image description here

1 Answer 1

0

You need to implement a DataProvider (DataSource) to your component. The DataProvider has the responsability to take the values from backend and set as a default value to your component.

Take a look at this: https://devdocs.magento.com/guides/v2.4/ui_comp_guide/concepts/ui_comp_data_source.html

1
  • This will not work as my edit form is not normal one. The attribute is added in product edit form in admin. My attribute value is getting saved but it is not populating Commented Apr 19, 2021 at 14:49

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.