First, I created the UI component: Vendor/Module/view/adminhtml/ui_component/product_form.xml
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <fieldset name="product-details"> <container name="fieldname_container"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="sortOrder" xsi:type="number">160</item> </item> </argument> <field name="fieldname" formElement="multiselect"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="dataScope" xsi:type="string">fieldname</item> <item name="filterOptions" xsi:type="boolean">true</item> <item name="showCheckbox" xsi:type="boolean">true</item> <item name="disableLabel" xsi:type="boolean">false</item> <item name="multiple" xsi:type="boolean">true</item> </item> </argument> <settings> <validation> <rule name="validate-field" xsi:type="boolean">true</rule> </validation> <dataType>varchar</dataType> <label translate="true">Field label</label> <dataScope>fieldname</dataScope> </settings> <formElements> <multiselect> <settings> <options class="Vendor\Module\Model\Backend\Product\Source\FieldName"/> </settings> </multiselect> </formElements> </field> </container> </fieldset> </form>
however when I save product the values of the custom attribute are not saved.
Created attribute and added it to product but now I have that field twice in product form. ( values are being saved )
If I remove created field from attribute set values are not being saved.
what is wrong here ?