How to observe event before saveShipping or saveBilling actions for address validation

Update: For my understanding (please correct me If I am wrong) the problem here is that the controller_action_predispatch_checkout_onepage_saveBilling gets dispatched and the following code is being executed (from Mage.php): public static function dispatchEvent($name, array $data = array()) { Varien_Profiler::start(‘DISPATCH EVENT:’.$name); $result = self::app()->dispatchEvent($name, $data); Varien_Profiler::stop(‘DISPATCH EVENT:’.$name); return $result; } the Object of type Mage_Core_model_Appthat is…

Add a block to programmatically generated widget

I need to generate a widget block with upgradeData.php and assign a block to this widget how can I do this? Folowing is my code for widget generation: Setup/UpgradeData.php public function __construct( \Magento\Cms\Model\BlockFactory $blockFactory, \Magento\Widget\Model\Widget\InstanceFactory $widgetFactory, \Magento\Framework\App\State $state ) { $this->blockFactory = $blockFactory; $this->widgetFactory = $widgetFactory; $this->state = $state; } /** * Upgrade data for…

Store the date value in a variable

Below code is used to add datepicker in magento2 front end. I need to store the selected date value in a varriable. how to do that echo $this->getLayout()->createBlock(‘Magento\Framework\View\Element\Html\Date’ )->setName( ‘date-range[from]’ )->setId( ‘from-date’ )->setValue( ” )->setImage( $this->getViewFileUrl(‘Magento_Theme::calendar.png’) )->setDateFormat( ‘y-MM-dd’ )->getHtml();