Set Default Value in Text Box in Magento Admin Custom Form

magento-1.7magento-1.8magento-1.9

I have create a field English video and save to data in database but I can't set value in edit time

I have used this code for set value.

$fieldset->addField('title', 'text', array(
            'label'     => Mage::helper('ultimate_option')->__('English Video'),
            'id'  => 'option_english',
            'name'      => 'option_english',
            'after_element_html' => '<table id="modulename_tbl_data_English" cellspacing="0">
                                <button id="English" class="add" type="button" title="Add"><span><span><span>Add</span></span></span></button>
                                </table>',
            'value'  => 'hello !!'         
        ));     

but getting this blank result

enter image description here

How can I set value for English text box at edit time.

Best Answer

I assume you have after the form definitions something like this:

$form->setData($data);

or

$form->addData($data);

If you do, add this line above it:

if (!isset($data['option_english'])) {
    $data['option_english'] = 'Your default value here';
}
Related Topic