In the previous article we described how to create your own section on the Magento 2 configuration page (Stores > Configuration).
In order to set the default values for the configuration fields, you need to create the following file in the module folder:
etc/config.xml
and add this code:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<section_id>
<group_id>
<field_id>default_value</field_id>
</group_id>
</section_id>
</default>
</config>
The section_id/group_id/field_id hierarchy has to match the structure in the system.xml file.
To clear the cache, run the CLI command:
php bin/magento cache:clean
Check the result.
In the examples, we create a module for FAQ. The modified module code can be viewed on GitHub.