For Magento (1.9) how to set the value to the Magento form.
$fieldset->addField('country_code', 'text', array(
'label' => Mage::helper('catalog')->__('Title3'),
'class' => 'required-entry',
'required' => true,
'name' => 'country_code',
'style' => "border:10px",
'value' => 'hello !!',
'disabled' => false,
'readonly' => true,
));
I set the value is hello !!
but it is not working.
Best Answer
Your problem is that values you set with
addField()
method are then overwritten withaddValues()
method which tries to set up a form fields values when form is used for editing existing entities or error occurred during submission.Here is a workaround. Most likely you are getting values with a protected method like this:
So inside of your
_prepareForm()
method you replace:with: