/** * Prepare form before rendering HTML * * @return \Magento\Backend\Block\Widget\Form */ protected function _prepareForm() { $this->_formHelper->addGoogleoptimizerFields($this->getForm(), $this->_getGoogleExperiment(), 'category_form'); $this->getForm()->getElement('googleoptimizer_fields')->setData(['legend' => null]); return parent::_prepareForm(); }
/** * Prepare form before rendering HTML * * @return $this * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _prepareForm() { $group = $this->getGroup(); $attributes = $this->getAttributes(); /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('group_' . $group->getId()); $form->setDataObject($this->getCategory()); $fieldset = $form->addFieldset('fieldset_group_' . $group->getId(), ['legend' => __($group->getAttributeGroupName()), 'class' => 'fieldset-wide']); if ($this->getAddHiddenFields()) { if (!$this->getCategory()->getId()) { // path if ($this->getRequest()->getParam('parent')) { $fieldset->addField('path', 'hidden', ['name' => 'path', 'value' => $this->getRequest()->getParam('parent')]); } else { $fieldset->addField('path', 'hidden', ['name' => 'path', 'value' => 1]); } } else { $fieldset->addField('id', 'hidden', ['name' => 'id', 'value' => $this->getCategory()->getId()]); $fieldset->addField('path', 'hidden', ['name' => 'path', 'value' => $this->getCategory()->getPath()]); } } $this->_setFieldset($attributes, $fieldset); if ($this->getCategory()->getLevel() == 1) { $fieldset->removeField('custom_use_parent_settings'); } else { if ($this->getCategory()->getCustomUseParentSettings()) { foreach ($this->getCategory()->getDesignAttributes() as $attribute) { if ($element = $form->getElement($attribute->getAttributeCode())) { $element->setDisabled(true); } } } if ($element = $form->getElement('custom_use_parent_settings')) { $element->setData('onchange', 'onCustomUseParentChanged(this)'); } } if ($this->getCategory()->hasLockedAttributes()) { foreach ($this->getCategory()->getLockedAttributes() as $attribute) { if ($element = $form->getElement($attribute)) { $element->setReadonly(true, true); } } } if (!$this->getCategory()->getId()) { $this->getCategory()->setIncludeInMenu(1); } $form->addValues($this->getCategory()->getData()); $this->_eventManager->dispatch('adminhtml_catalog_category_edit_prepare_form', ['form' => $form]); $form->setFieldNameSuffix('general'); $this->setForm($form); return parent::_prepareForm(); }
/** * Prepare form before rendering HTML * * @return \Magento\Backend\Block\Widget\Form */ protected function _prepareForm() { $this->_formHelper->addGoogleoptimizerFields($this->getForm(), $this->_getGoogleExperiment()); return parent::_prepareForm(); }