setTemplate('Magento_Config::system/config/form/field/array.phtml'); } /** * Prepare rendering the new field by adding all the needed columns */ protected function _prepareToRender() { $this->addColumn('vendor_name', [ 'label' => __('Vendor Name'), 'class' => 'required-entry', 'style' => 'width:200px' ]); $this->addColumn('note', [ 'label' => __('Note'), 'class' => 'required-entry', 'style' => 'width:400px' ]); $this->_addAfter = false; $this->_addButtonLabel = __('Add Vendor Note'); } /** * Obtain existing data from form element * * Each row will be instance of Varien_Object * * @return array */ public function getArrayRows() { $result = []; /** @var DataObject $row */ foreach (parent::getArrayRows() as $key => $row) { // Ensure row IDs are prefixed with underscore to make valid CSS selectors // CSS IDs cannot start with a number if (is_numeric($key)) { $key = '_' . $key; } // Also set the _id property in the row data for proper rendering $row->setData('_id', $key); $result[$key] = $row; } return $result; } /** * Prepare existing row data object * * @param DataObject $row * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareArrayRow(DataObject $row): void { $options = []; $row->setData('option_extra_attrs', $options); } }