I want to save the data in of a custom dynamicrows field. which i added on admin category page. my custom_form.xml:
<?xml version="1.0"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="general">
<dynamicRows name="dynamic_rows">
<settings>
<addButtonLabel translate="true">Add Record</addButtonLabel>
<additionalClasses>
<class name="admin__field-wide">true</class>
</additionalClasses>
<componentType>dynamicRows</componentType>
</settings>
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="isTemplate" xsi:type="boolean">true</item>
<item name="is_collection" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">container</item>
</item>
</argument>
<field name="selected_product_attributes">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">VendorModuleModelCategoryAttributeSourceProductAttributes</item>
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" xsi:type="string" translate="true">Product Attributes</item>
<item name="source" xsi:type="string">category</item>
<item name="dataScope" xsi:type="string">selected_product_attributes</item>
<item name="sortOrder" xsi:type="number">40</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
</item>
</argument>
</field>
</container>
</dynamicRows>
</fieldset>
</form>
and my VendorModuleModelCategoryAttributeSourceProductAttributes.php is:
<?php
namespace VendorModuleModelCategoryAttributeSource;
use MagentoFrameworkOptionArrayInterface;
class ProductAttributes extends MagentoEavModelEntityAttributeSourceAbstractSource
{
protected $_productAttributeCollectionFactory;
public function __construct(
MagentoCatalogModelResourceModelProductAttributeCollectionFactory $productAttributeCollectionFactory
) {
$this->_productAttributeCollectionFactory = $productAttributeCollectionFactory;
}
/**
* {@inheritdoc}
*/
public function getAllOptions()
{
$result = [];
$attributes = $this->_productAttributeCollectionFactory->create();
foreach ($attributes as $attribute) {
$result[] = [
'label' => $attribute->getStoreLabel(),
'value' => $attribute->getAttributeCode(),
];
}
return $result;
}
}
I don’t know what should I do next.