Add functions to Zend_Form_Element
Hello,
I've tried to extend Zend_Form_Element without success. I want to add some functions like
class Form_Element extends Zend_Form_Element
{
protected $_unit = '';
protected $_elementId;
/**
* Set element unit
*
* @param string $unit
* @return void
*/
public function setUnit($unit)
{
$this->_unit = (string) $unit;
}
/**
* Retrieve element unit
*
* @return string
*/
public function getUnit()
{
return $this->_unit;
}
/**
* Set element id
*
* @param integer $elementId
* @return void
*/
public function setElementId($elementId)
{
$this->_elementId = (string) $elementId;
}
/**
* Retrieve element id
*
* @return integer
*/
public function getElementId()
{
return $this->_elementId;
}
}
With those functions I can access the given unit in the decorator with $this->element->getUnit(), that's what I'm trying to achiv. But unfortunately I just can't find a smooth way to do it properly. When I use $form->addPrefixPath it would work, but only if I redefine all Zend_Form_Element_* elements.
By the way: My current quick and dirty solutions is to extend Zend_Form_Element:
class Zend_Form_Element extends Form_Element implements Zend_Validate_Interface
{}
But this way I would have to update this file every time I'll do a SVN Update of the framework...
Any solutions or suggestions?
Thanks in advance.