Example #1
0
 public function testAddFieldset()
 {
     $config = ['name' => 'store_type', 'no_span' => true, 'value' => 'value'];
     $this->factoryElementMock->expects($this->once())->method('create')->with('fieldset', ['data' => $config])->will($this->returnValue($this->elementMock));
     $this->elementMock->expects($this->once())->method('setId')->with('hidden');
     $this->elementMock->expects($this->once())->method('setAdvanced')->with(false);
     $this->elementMock->expects($this->once())->method('setForm');
     $this->factoryCollectionMock->expects($this->once())->method('create')->will($this->returnValue($this->allElementsMock));
     $this->allElementsMock->expects($this->once())->method('add')->with($this->elementMock, false);
     $this->abstractForm->addFieldset('hidden', $config);
 }
Example #2
0
 /**
  * Initialize config field group
  *
  * @param \Magento\Backend\Model\Config\Structure\Element\Group $group
  * @param \Magento\Backend\Model\Config\Structure\Element\Section $section
  * @param \Magento\Framework\Data\Form\AbstractForm $form
  * @return void
  */
 protected function _initGroup(\Magento\Backend\Model\Config\Structure\Element\Group $group, \Magento\Backend\Model\Config\Structure\Element\Section $section, \Magento\Framework\Data\Form\AbstractForm $form)
 {
     $frontendModelClass = $group->getFrontendModel();
     $fieldsetRenderer = $frontendModelClass ? $this->_layout->getBlockSingleton($frontendModelClass) : $this->_fieldsetRenderer;
     $fieldsetRenderer->setForm($this);
     $fieldsetRenderer->setConfigData($this->_configData);
     $fieldsetRenderer->setGroup($group);
     $fieldsetConfig = ['legend' => $group->getLabel(), 'comment' => $group->getComment(), 'expanded' => $group->isExpanded(), 'group' => $group->getData()];
     $fieldset = $form->addFieldset($this->_generateElementId($group->getPath()), $fieldsetConfig);
     $fieldset->setRenderer($fieldsetRenderer);
     $group->populateFieldset($fieldset);
     $this->_addElementTypes($fieldset);
     $dependencies = $group->getDependencies($this->getStoreCode());
     $elementName = $this->_generateElementName($group->getPath());
     $elementId = $this->_generateElementId($group->getPath());
     $this->_populateDependenciesBlock($dependencies, $elementId, $elementName);
     if ($group->shouldCloneFields()) {
         $cloneModel = $group->getCloneModel();
         foreach ($cloneModel->getPrefixes() as $prefix) {
             $this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']);
         }
     } else {
         $this->initFields($fieldset, $group, $section);
     }
     $this->_fieldsets[$group->getId()] = $fieldset;
 }