Question

How to submit the magento 2.0.6 custom module admin config form using events and observers

i want to submit the my custom module form using events and observers

Was it helpful?

Solution

app\code\Vendor\Module_Name\etc\adminhtml\events.xml

  <?xml version="1.0"?>
  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="your_event_name_here">
       <observer name="vendor_modulename_event_obs"  instance="Vendor\Module_Name\Model\MyEvent" 
    method="execute"/>
</event>
</config>

app\code\Vendor\Module_Name\Model\MyEvent.php

  <?php

     namespace Vendor\Module_Name\Model;

     use Magento\Framework\Event\ObserverInterface;

      class MyEvent implements ObserverInterface{

          //declare required object under construct 
         public function __construct() {}
         public function execute(\Magento\Framework\Event\Observer  $observer)                       {
                     //Script here
                    $dateObj = $observer->getData();
                           }
     }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top