Try extending Zend_Form to do it automatically for you.
class My_Form extends Zend_Form()
{
...
private function _getUniqueId() {
$names = $this->getId();
foreach ($this->getElements() as $element) {
$names .= $element->getName();
}
return md5($names);
}
/**
* Unique identifier for this form
* @return string
*/
public function getIdentifier()
{
if (null !== $this->_identifier) {
return $this->_identifier;
}
$id = $this->getId();
if (empty($id)) {
$id = $this->getName();
}
if (empty($id)) {
$id = $this->_getUniqueId();
}
$id = 'form_' . $id;
$this->_identifier = $id;
return $id;
}
/**
* Add to the form hidden field with unique identifier
*/
private function _addIdentifier()
{
//if (!$this->_identifierAdded) {
$name = $this->getIdentifier();
$element = new Zend_Form_Element_Hidden($name);
$this->addElement($element);
// $this->_identifierAdded;
//}
}
public function render($view = null)
{
$this->_addIdentifier();
return parent::render($view);
}
}
--
regards
takeshin
--
View this message in context:
http://n4.nabble.com/Setting-form-element-id-tp1557052p1557210.html
Sent from the Zend Framework mailing list archive at Nabble.com.