ZF-6691: Zend_Form_Element: Allow hyphen in element names / Manually set label's decorator ID
Description
Could we allow hyphen (-) in the charset in Zend_Form_Element's filterName() function?
Or have the ability to manually set the ID of the label's HtmlTag's Decorator? It currently relies on the element's name:
// Zend_Form_Decorator_Label
// render()
if (null !== $tag) {
require_once 'Zend/Form/Decorator/HtmlTag.php';
$decorator = new Zend_Form_Decorator_HtmlTag();
$decorator->setOptions(array('tag' => $tag,
'id' => $this->getElement()->getName() . '-label'));
$label = $decorator->render($label);
}
May be overkill, but I want to prepend the form's id to all the element, dt, and dd ids.
Trying to achieve the following:
Email Address
But does this instead:
Email Address
I haven't had much luck with an easy work around for the label's ID. Any suggestions other than using custom decorators?
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2009-05-17T20:11:30.000+0000
hyphens are not allowed in element names as element names may only be valid PHP variable names in order to allow overloading. We may review this decision in the future, but for now, that decision stands.