Example #1
0
 /**
  * Enter description here...
  *
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initForm()
 {
     $this->_initObjects();
     $form = new Varien_Data_Form();
     $sections = $this->_configFields->getSection($this->getSectionCode(), $this->getWebsiteCode(), $this->getStoreCode());
     if (empty($sections)) {
         $sections = array();
     }
     foreach ($sections as $section) {
         /* @var $section Varien_Simplexml_Element */
         if (!$this->_canShowField($section)) {
             continue;
         }
         foreach ($section->groups as $groups) {
             $groups = (array) $groups;
             usort($groups, array($this, '_sortForm'));
             foreach ($groups as $group) {
                 /* @var $group Varien_Simplexml_Element */
                 if (!$this->_canShowField($group)) {
                     continue;
                 }
                 $this->_initGroup($form, $group, $section);
             }
         }
     }
     $this->setForm($form);
     return $this;
 }
Example #2
0
 /**
  * Enter description here...
  *
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initForm()
 {
     $this->_initObjects();
     $form = new Varien_Data_Form();
     $sections = $this->_configFields->getSection($this->getSectionCode(), $this->getWebsiteCode(), $this->getStoreCode());
     if (empty($sections)) {
         $sections = array();
     }
     foreach ($sections as $section) {
         /* @var $section Varien_Simplexml_Element */
         if (!$this->_canShowField($section)) {
             continue;
         }
         foreach ($section->groups as $groups) {
             $groups = (array) $groups;
             usort($groups, array($this, '_sortForm'));
             foreach ($groups as $group) {
                 /* @var $group Varien_Simplexml_Element */
                 if (!$this->_canShowField($group)) {
                     continue;
                 }
                 if ($group->frontend_model) {
                     $fieldsetRenderer = Mage::getBlockSingleton((string) $group->frontend_model);
                 } else {
                     $fieldsetRenderer = $this->_defaultFieldsetRenderer;
                 }
                 $fieldsetRenderer->setForm($this);
                 $fieldsetRenderer->setConfigData($this->_configData);
                 $fieldsetRenderer->setGroup($group);
                 if ($this->_configFields->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) {
                     $helperName = $this->_configFields->getAttributeModule($section, $group);
                     $fieldsetConfig = array('legend' => Mage::helper($helperName)->__((string) $group->label));
                     if (!empty($group->comment)) {
                         $fieldsetConfig['comment'] = (string) $group->comment;
                     }
                     $fieldset = $form->addFieldset($section->getName() . '_' . $group->getName(), $fieldsetConfig)->setRenderer($fieldsetRenderer);
                     $this->_addElementTypes($fieldset);
                     if ($group->clone_fields) {
                         if ($group->clone_model) {
                             $cloneModel = Mage::getModel((string) $group->clone_model);
                         } else {
                             Mage::throwException('Config form fieldset clone model required to be able to clone fields');
                         }
                         foreach ($cloneModel->getPrefixes() as $prefix) {
                             $this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']);
                         }
                     } else {
                         $this->initFields($fieldset, $group, $section);
                     }
                     $this->_fieldsets[$group->getName()] = $fieldset;
                 }
             }
         }
     }
     $this->setForm($form);
     return $this;
 }