Magento – field of type link in admin form is not rendering value

adminblockscatalogformsmagento-1.7

My class extends from Mage_Adminhtml_Block_Widget_Form, which has declaration for _prepareForm method with code for myfield as follows

  $fieldset->addField('myElementId', 'link', array(
      'label'     => 'myLabel',
      'href' => 'http://magento.stackexchange.com',
      'value'  => 'myElementValue'
    ));

This field is rendering all except value (i.e, myElementValue).

Can any one help me with this?

Billions of Thanks in Advance

EDIT:

My class name – MyNameSpace_MyModule_Block_Adminhtml_MyBlockGroup_ClassExtendingFormContainer_Tab_Form

This class defines the _prepareForm function as follows:

 protected function _prepareForm()
 {
       $form = new Varien_Data_Form();
       $this->setForm($form);
       $fieldset = $form->addFieldset('someElementId',array('key'=>'value'));          

      $fieldset->addField('myElementId', 'link', array(
                      'label'     => 'myLabel',
             'href' => 'http://magento.stackexchange.com/',
              'value'  => 'myElementValue',
            ));

      $fieldset->addField('myElementId2', 'text', array(
                    'label' => 'myLabel2',
                    'name' => 'myElementId2',
             ));

  $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
      $fieldset->addField('myElementId3', 'date', array(
                     'name'   => 'myElementId3',
                     'label'  => 'myLabel3',
                     'width'=>"100px",
                     'image'  => $this->getSkinUrl('images/grid-cal.gif'),
                     'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
                     'format'       => $dateFormatIso,
                     'time' => true, 
        ));

     if ( Mage::registry('SomeRegistrySetinCurrentControllerAction') )
     {
       $form->setValues(Mage::registry('SomeRegistrySetinCurrentControllerAction')->getData());
 }

 return parent::_prepareForm();
 }

It is rendering date, text fields in the form but not link.

Best Answer

Your code works (almost) correctly.
The value of the link field is not shown because it is overwritten by $form->setValues(...).
Here is how Varien_Data_Form::setValues() works

public function setValues($values)
    {
        foreach ($this->_allElements as $element) { //for each element in the form
            if (isset($values[$element->getId()])) {//if there is a value in the values for the element set the value of that element.
                $element->setValue($values[$element->getId()]);
            }
            else {//if there is no value for the element set its value to null.
                $element->setValue(null);
            }
        }
        return $this;
    }

I recommend using $form->addValues(...); this one does not set to null the missing values in the parameter passed to it.