How to use custom html element in admin form field?

Renderer file:

class NameSpace]_[ModuleName]_Block_Adminhtml_Review_Renderer_Images extends  Varien_Data_Form_Element_Abstract
{
    
    public function getElementHtml()
    {   
    
        $html = '';         
            $html = $html.'<input id="input-21d" name="rating" value="2" type="number" class="rating" min=0 max=5 step=0.5 data-size="sm" data-disabled="true">';           
        return $html;
    }
}

in your form.php

$fieldset->addType('customtype', '[NameSpace]_[ModuleName]_Block_Adminhtml_Review_Renderer_Images');     
     $fieldset->addField('rating', 'customtype', array(
        'name'      => 'rating',
        'label'     => Mage::helper('[modulename]')->__('Rating'),
    ));

using this you can use custom html in admin form field


you are almost correct here i suggest you about my working example to display image of field in grid

Grid.php

$this->addColumn('after_image', array(
          'header'    => Mage::helper('testimonials')->__('After Image'),
          'align'     =>'left',
          'index'     => 'after_image',
          'renderer'  => 'testimonials/adminhtml_testimonials_edit_renderer_testimonialafimage',
      ));

where testimonials is your block tag in config.xml

and your render file should be like as define in your renderer index

<?php
class Yournamespace_Testimonials_Block_Adminhtml_Testimonials_Edit_Renderer_Testimonialafimage extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
  {
     public function render(Varien_Object $row)
    {       

        if($row->getId()) {             
         $imageName = $row->getAfterImage();                
        $imagePath = Mage::getBaseUrl("media").$imageName; 
        $dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imagePath,'/media'));        

        if (file_exists($dirImg) && !empty($imageName)) {           
            return  "<img width='50px' height='50px' src='".Mage::getBaseUrl("media").$imageName."' />"; 
        }else{
             return  "<img width='50px' height='50px' src='".Mage::getBaseUrl("media").'testimonial/not-available.jpg'."' />"; 
        }          
        }
    }  
}     
 ?>

EDIT

Use renderer in Edit form you can see rating edit form of admin

class Mage_Adminhtml_Block_Rating_Edit_Tab_Form

 $field = $fieldset->addField('stores', 'multiselect', array(
            'label' => Mage::helper('rating')->__('Visible In'),
            'name' => 'stores[]',
            'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
        ));
        $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
        $field->setRenderer($renderer);

hope this will be enough to get idea.