Question

In system.xml one can simply use elements like text and select and all the tutorials out there are using these two as examples. But how should I use other elements listed in lib/Varien/Data/Form/Elements folder?

For example there is a Fieldset and I noticed that it has getLegend and getElements methods but adding <legend>Some Text</legend> or <elements><!-- Elements --></elements> nodes did not work. How should I use them?

Was it helpful?

Solution

Mage_Adminhtml_Block_System_Config_Form::initFields is responsible for generating fields from system.xml. It uses frontend_type to figure out which element to generate

$fieldType  = (string)$element->frontend_type ? (string)$element->frontend_type : 'text';

And generating code itself:

     $field = $fieldset->addField($id, $fieldType, array(
                'name'                  => $name,
                'label'                 => $label,
                'comment'               => $comment,
                'tooltip'               => $tooltip,
                'hint'                  => $hint,
                'value'                 => $data,
                'inherit'               => $inherit,
                'class'                 => $element->frontend_class . $sharedClass . $requiresClass,
                'field_config'          => $element,
                'scope'                 => $this->getScope(),
                'scope_id'              => $this->getScopeId(),
                'scope_label'           => $this->getScopeLabel($element),
                'can_use_default_value' => $this->canUseDefaultValue((int)$element->show_in_default),
                'can_use_website_value' => $this->canUseWebsiteValue((int)$element->show_in_website),
            ));

$fieldset is here type of Varien_Data_Form_Element_Fieldset.

So using system.xml you can create any elements of Varien_Data_Form_Element_*. But there is a limit for input parameterss from xml config.

Made a small investigation for possible parameters, so they are:

  • frontend_model
  • frontend_type
  • label
  • hint
  • backend_model
  • comment
  • tooltip
  • tooltip_block
  • depends
  • shared
  • requires
  • validate
  • can_be_empty
  • source_model
  • if_module_enabled
  • show_in_default
  • show_in_website
  • show_in_store
  • config_path

All other will be ignored.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top