My config file
after save config data
After save data It also show error in console as there is no any field
after save data it does not give me unserialaize data my php file to render data in table is
<?php
namespace Vendor\Module\Block\Adminhtml;
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Vendor\Module\Block\Adminhtml\PaymentMethod;
use Vendor\Module\Block\Adminhtml\UnitMethod;
class Payment extends AbstractFieldArray
{
private $pymentRenderer;
private $unitRenderer;
protected function _prepareToRender()
{
$this->addColumn('paymentmethod', [
'label' => __('Payment Method'),
'renderer' => $this->getPaymentRenderer()
]);
$this->addColumn('duration', ['label' => __('Duration'), 'class' => 'required-entry']);
$this->addColumn('unit', [
'label' => __('Units'),
'renderer' => $this->getUnitRenderer()
]);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
protected function _prepareArrayRow(DataObject $row): void
{
$options = [];
$pm = $row->getPaymentMethod();
$unit = $row->getUnitMethod();
if ($pm !== null) {
$options['paymentmethod_' . $this->getPaymentRenderer()->calcOptionHash($pm)] = 'selected="selected"';
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info(print_r($options,true));
$row->setData('paymentmethod', $options);
}
$options = [];
if ($unit !== null) {
$options['unit_' . $this->getUnitRenderer()->calcOptionHash($unit)] = 'selected="selected"';
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info(print_r($options,true));
$row->setData('unit', $options);
}
}
private function getPaymentRenderer()
{
if (!$this->pymentRenderer) {
$this->pymentRenderer = $this->getLayout()->createBlock(
paymentmethod::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
}
return $this->pymentRenderer;
}
private function getUnitRenderer()
{
if (!$this->unitRenderer) {
$this->unitRenderer = $this->getLayout()->createBlock(
unitmethod::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
}
return $this->unitRenderer;
}
}