在library/Application/Form/Element/Img.php中有
class Application_Form_Element_Img extends Zend_Form_Element_Xhtml
{
public $helper = 'formImg';
public function loadDefaultDecorators ()
{
parent::loadDefaultDecorators ();
$this->removeDecorator ('Label');
$this->removeDecorator ('HtmlTag');
$this->addDecorator('HtmlTag', array (
'tag' => 'span',
'class' => 'myElement',
));
}
}
在应用程序/视图/helpers/FormImg.php
class Zend_View_Helper_FormImg extends Zend_View_Helper_FormElement
{
public function formImg ($name, $value, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
$xHtml = '<img'
. $this->_htmlAttribs ($attribs)
. ' />';
return $xHtml;
}
}
在你的表格中:
$this->addElement ('img', 'myimage', array (
'src' => '/images/download.png',
'align' => 'right',
));
Note:路径可能会在您的特定应用程序中发生变化。