/** * Add fields to main fieldset based on specified tab type * * @return Mage_Adminhtml_Block_Widget_Form */ public function addFields() { // get configuration node and translation helper if (!$this->getWidgetType()) { throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a Widget Type.')); } $config = $this->tabsOptionsFactory->create()->getConfigAsObject($this->getWidgetType()); if (!$config->getParameters()) { return $this; } foreach ($config->getParameters() as $parameter) { $this->_addField($parameter); } return $this; }
/** * Return array of available widgets based on configuration * * @param bool $withEmptyElement * @return array */ protected function _getAvailableWidgets($withEmptyElement = false) { if (!$this->hasData('available_widgets')) { $result = []; $allWidgets = $this->tabsOptionsFactory->create()->getTabsArray(); foreach ($allWidgets as $widget) { $result[] = $widget; } if ($withEmptyElement) { array_unshift($result, ['type' => '', 'name' => __('-- Please Select --'), 'description' => '']); } $this->setData('available_widgets', $result); } return $this->_getData('available_widgets'); }