How to Add dropdown field from admin form

Add dropdown field from admin form:

1. Select your form file from admin
Ex: Jute_Mymodule_Block_Adminhtml_Form_Edit_Form

protected function _prepareForm()
{
$form = new Varien_Data_Form(array(
‘id’ => ‘edit_form’,
‘action’ => $this->getUrl(‘*/*/save’, array(‘_current’ => true)),
‘method’ => ‘post’,
‘enctype’=> ‘multipart/form-data’
));

$outputArr = Mage::helper(‘MYHELPER’)->getvaluefromCustomfunction();

$fieldset->addField(‘myfield’, ‘select’, array(
‘label’ => Mage::helper(‘MYHELPER’)->__(‘MyField Label’),
‘class’ => ‘required-entry’,
‘name’ => ‘myfield’,
‘required’ => true,
‘disabled’ => false,
‘values’ => $outputArr
));

$form->setUseContainer(true);
$this->setForm($form);

return parent::_prepareForm();
}

2. Add you function as like below way into your helper class

class Jute_Mymodule_Helper_Data extends Mage_Core_Helper_Abstract{
public function getActiveDFBranch(){
$outputArra = array(1 => ‘My dropdown value 1’,2 => ‘My dropdown value 2’);
}
return $outputArra;
}
}

3. Clear cache and check

————————————————————————————————————————————————————————————-

Corner of Blog:

” Keep Calm  Help Others !!! “

———————————————————————————————————————————————————————————————-