To create a table configuration in Magento2 backend, we can use some good tutorial in here: http://www.ibnab.com/en/blog/magento-2/magento-2-backend-guide-to-create-table-setting-in-the-system-configuration or https://magently.com/blog/magento-2-backend-configuration-frontend-model-part-33/

I read this tutorial in Magento 1 https://www.integer-net.com/how-to-create-tables-in-magento-system-configuration/.

They created a table configuration with default value. I knew that in Magento 1, we can set default array value for table in config.xml like that:


I try to put the same array above from Magento 1 to config.xml file on Magento 2, but it does not work at all.

Here is my example:


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <tab id="media" translate="label" sortOrder="300">
    <section id="payment" translate="label" type="text" sortOrder="402" showInDefault="1" showInWebsite="1" showInStore="1">
        <group id="setting" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
            <field id="interest_rates" translate="label comment" sortOrder="13" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Interest Rates</label>

File InterestRates

protected function _prepareToRender()
    $this->addColumn('duration', ['label' => __('Duration'), 'style' => 'width:60px']);
    $this->addColumn('effective_interest_rate', ['label' => __('Effective Interest Rate'), 'style' => 'width:170px']);
    $this->addColumn('special_effective_interest_rate', ['label' => __('Special Effective Interest Rate'), 'style' => 'width:170px']);
    $this->_addAfter = false;
    $this->_addButtonLabel = __('Add Interest Rate');

Picture demo enter image description here

I want to set default value for text column Duration, Effective_Interest_Rate and Special Effective Interest Rate

Can someone give me an advice? How can I set default value for table configuration in Magento .

  • Please share your system.xml file to get proper response. Commented Jan 13, 2017 at 10:09
  • Hi I updated my questions, I need to set default value for text column above Commented Jan 13, 2017 at 10:34

3 Answers 3


In your case, you can follow the same Magento 1 way, you have to enter a serialized array there. From my experience, the best way to generate that serialized array is to fill in the default data in the backend, save it and then copy the value from core_config_data table to the config.xml.

For example config xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">

We can use this site http://www.unserialize.com/ to check our serialized array.

  • Thanks a lot. I just got value from table core_config_data and it works really well Commented Jan 17, 2017 at 10:56
  • It works, But after setting default config value, it still shows the fields as editable, Ho do I disable the fields while default value is set ?
    – Jaisa
    Commented Aug 9, 2018 at 8:29
  • After module install, I see that config value are display in admin side. But when I get that config then I get error. I need to save it and then able to get it. config.xml save data in core_config_data or not? Commented Dec 19, 2019 at 10:40
  • @Khoa this is helpfull for me Commented Jan 20, 2020 at 15:11

Below code for set yes value to dropdown file Yes/No.

In config.xml file,

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
  • Hi Rakesh, can you explain please? Why do we set only <enable>1</enable>. I want to set default value for text column in table configuration Commented Jan 13, 2017 at 10:10
  • This is example for only Yes/No value, you can set text value as well but you have to define system.xml code in your question. Commented Jan 13, 2017 at 10:12
  • Please check updated answer, above code set 100 value to shipping cost textfield in configuration. Commented Jan 13, 2017 at 10:13
  • please check my updated answer. Commented Jan 13, 2017 at 10:34
  • Thanks, but I still dont understand. I have 3 text columns, can you explain? Why do you set only <interest_rates>100</interest_rates>. I think, do we need to set an array here and how is the format of an array? <interest_rates>array_format_magento2</interest_rates> Commented Jan 13, 2017 at 10:37

Sample for new carrier. You can easily set default value for all types of fields

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
                <name>Poczta Polska</name>


Cant You use something like that:

    $this->addColumn('duration', ['label' => __('Duration'), 'style' => 'width:60px', 'default' => 'xxx']);


    $this->addColumn('duration', ['label' => __('Duration'), 'style' => 'width:60px', 'value' => 'xxx']);
  • Thanks a lots, but I want to set default value for table configuration, I updated my question. Maybe can you take a look again? Commented Jan 13, 2017 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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