0

I'm trying to make a custom store configuration with ArraySerialized
But at first, i try with 2 column and it working fine, i've successfully in created and get data from it, but then, i created 1 more column, and this issue show up enter image description here

I've searched a lot but still no luck, please help

Here's what i done:

etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="gssi_career" translate="label" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>Careers</label>
            <tab>gssi</tab>
            <resource>Gssi_Contact::contact_config</resource>

            <group id="gssi_career_group" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Career Subject</label>
                <field id="gssi_career_field" translate="label" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>List Careers</label>
                    <frontend_model>Gssi\Career\Block\System\Config\Form\Field\Fields</frontend_model>
                    <backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
                </field>
            </group>

        </section>

    </system>
</config>

Gssi\Career\Block\System\Config\Form\Field\Fields

<?php   
namespace Gssi\Career\Block\System\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;

/**
 * Class Active
 *
 * @package Gssi\Contact\Block\System\Config\Form\Field
 */
class Fields extends AbstractFieldArray {

    /**
     * @var bool
     */
    protected $_addAfter = TRUE;

    /**
     * @var
     */
    protected $_addButtonLabel;

    /**
     * Construct
     */
    protected function _construct() {
        parent::_construct();
        $this->_addButtonLabel = __('Add');
    }

    /**
     * Prepare to render the columns
     */
    protected function _prepareToRender() {
        $this->addColumn('subject_code', ['label' => __('Subject Code')]);
        $this->addColumn('subject_label', ['label' => __('Subject Label')]);
        $this->addColumn('subject_email', ['label' => __('Subject Email')]);
        $this->_addAfter       = FALSE;
        $this->_addButtonLabel = __('Add');
    }
}
0

Simple....Remove your config entry in core_config_data. Try adding all columns at a time in protected function _prepareToRender() and run upgrade, compile and flush commands

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.