0

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

2

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();
                           }
     }

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.