Fieldset in system configuration - Magento Admin m

2019-09-18 19:50发布

问题:

I am creating an admin module. I have set of fields and i want to create a fieldset each of 3 fields in system configuration, i have created fields but wanted to add fieldset in it. Any help would be appreciated. Thank you

回答1:

You haven't given much information i.e Layout of your module, whether you are adding fields in code or .phtml but this is how I am adding fields to a field set:

protected function _prepareForm()
{
    $form = new Varien_Data_Form();
    $this->setForm($form);

    $fieldset = $form->addFieldset('form_settings', array('legend'=>Mage::helper('mymodule')->__('Module Settings')));

    $newFieldset = $fieldset->addFieldset('form_settings_test', array('legend'=>Mage::helper('khaosconnect')->__('Order Settings')));

    $newFieldset->addField('mysetting1', 'text', array(
        'label'     => Mage::helper('mymodule')->__('Setting 1'),
        'class'     => 'required-entry',
        'required'  => true,
        'name'      => 'mysetting1',
        'value'     => "val1",
        'style'     => 'width:500px'
    ));

    $newFieldset->addField('mysetting2', 'text', array(
        'label'     => Mage::helper('mymodule')->__('Setting 2'),
        'class'     => 'required-entry',
        'required'  => true,
        'name'      => 'mysetting2',
        'value'     => "val2",
        'style'     => 'width:500px'
    ));
}

EDIT: Updated to show nested fieldsets.



标签: magento