15/08/2022
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
<section id="mytab" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Configuration</label>
<field id="name" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter Name</label>
</field>
</group>
</section>
The section id is mytab which has to be added in the event name.
Directory
app/code/VendorName/ModuleName/etc/adminhtml/events.xml
Content of events.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="admin_system_config_changed_section_mytab">
<observer name="custom_admin_system_config_changed_section_mytab" instance="VendorName\ModuleName\Observer\ConfigChange"/>
</event>
</config>
Directory
app/code/VendorName/ModuleName/Observer/ConfigChange.php
Content of ConfigChange.php
<?php
namespace VendorName\ModuleName\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
class ConfigChange implements ObserverInterface
{
private $request;
private $configWriter;
public function __construct(RequestInterface $request, WriterInterface $configWriter)
{
$this->request = $request;
$this->configWriter = $configWriter;
}
public function execute(EventObserver $observer)
{
$meetParams = $this->request->getParam('groups');
$name = $meetParams['general']['fields']['name']['value'];
//to print thatn value in system.log
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info($name);
return $this;
}
}
?>