#StackBounty: #magento2 #magento-2.1 Magento 2 create admin config table with custom rows and columns

Bounty: 50

I want to create admin config with a table to take the data and save in config for that I followed this link.

But I also want to create custom rows in that table programmatically and also without the last action column and add button. Please refer the image
Admin Config

I was unable to find any solution on the web regarding the same nor the file

MagentoConfigBlockSystemConfigFormFieldFieldArrayAbstractFieldArray

that we extend gave any clues.

Could have easily done this via jquery but want to implement the standard solution.

Code:

<?php
namespace AbcPaymentmethodBlockAdminhtmlSystemConfigFormField;

class Feetable extends MagentoConfigBlockSystemConfigFormFieldFieldArrayAbstractFieldArray
{
    /**
     * @var MagentoFrameworkDataFormElementFactory
     */
    protected $_elementFactory;

    /**
     * @param MagentoBackendBlockTemplateContext $context
     * @param MagentoFrameworkDataFormElementFactory $elementFactory
     * @param array $data
     */
    public function __construct(
        MagentoBackendBlockTemplateContext $context,
        MagentoFrameworkDataFormElementFactory $elementFactory,
        array $data = []
    )
    {
        $this->_elementFactory  = $elementFactory;
        parent::__construct($context,$data);
    }
    protected function _construct(){
        $this->addColumn('noi', ['label' => __('NOI'),'readonly'=>'readonly']);
        $this->addColumn('fixed', ['label' => __('Fixed')]);
        $this->addColumn('percent', ['label' => __('Percent')]);
        $this->_addAfter = false;
        $this->_addButtonLabel = __('Add More');
        parent::_construct();
    }

    protected function _prepareArrayRow(MagentoFrameworkDataObject $row) {
        $options = [1,2,3];
        $row->setData('option_extra_attrs', $options);
    }

}

system.xml

<field id="abc_fee_table" translate="label comment tooltip" sortOrder="17.4" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Abc Fee by Number of Installments(NOI)</label>
                    <frontend_model>AbcPaymentmethodBlockAdminhtmlSystemConfigFormFieldFeetable</frontend_model>
                    <backend_model>MagentoConfigModelConfigBackendSerializedArraySerialized</backend_model>                    
                </field>


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.