_initWidgetInstance(); $layout = $this->getRequest()->getParam('layout'); $selected = $this->getRequest()->getParam('selected', null); $blocksChooser = $this->_view->getLayout()->createBlock( 'Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container' )->setValue( $selected )->setArea( $widgetInstance->getArea() )->setTheme( $widgetInstance->getThemeId() )->setLayoutHandle( $layout )->setAllowedContainers( $widgetInstance->getWidgetSupportedContainers() ); $this->setBody($blocksChooser->toHtml()); } /** * Blocks Action (Ajax request) * * @return void */ public function execute() { $this->_objectManager->get( 'Magento\Framework\App\State' )->emulateAreaCode( 'frontend', [$this, 'renderPageContainers'] ); } }