Hi,
Looking at it I can see I *can* set null as the value, as per:
if (null === $value) {
unset($this->$name);
But I presume some decorator or other render method replaces attribute "id"
with the "name" attribute value if "id" equals null
I haven't been able to figure out where this is though. I looked in:
Zend_Form_Element
Zend_Form_Element_Hidden (which I need it for)
Zend_Form_Element_Xhtml
Zend_Form_Decorator_Abstract
Zend_Form_Decorator_FormElements
Zend_Form_Decorator_HtmlTag
...all to no avail. So any other pointers much appreciated.
Cheers
Date: Wed, 1 Apr 2009 11:09:54 +0300
Subject: Re: [fw-general] Disable id attribute for form elements?
From: [email protected]
To: [email protected]
CC: [email protected]
Hi,
looking at Form/Element.php at the setAttrib function you can understand how
the function works. you can tell that you can't just set null as the value.
/**
* Set element attribute
*
* @param string $name
* @param mixed $value
* @return Zend_Form_Element
* @throws Zend_Form_Exception for invalid $name values
*/
public function setAttrib($name, $value)
{
$name = (string) $name;
if ('_' == $name[0]) {
require_once 'Zend/Form/Exception.php';
throw new Zend_Form_Exception(sprintf('Invalid attribute "%s"; must
not contain a leading underscore', $name));
}
if (null === $value) {
unset($this->$name);
} else {
$this->$name = $value;
}
return $this;
}
Vince.
On Wed, Apr 1, 2009 at 10:31 AM, <[email protected]> wrote:
Hi all,
Is there a way to disable the rendering of id attributes for form elements? I'm
building a CMS which displays a tree of pages that can be edited. The tree
consists of multiple forms for each page. I'ld rather not create unique for all
of them.
I tried:
Zend_Form_Element::setAttrib( 'id', '' ); // results in invalid W3C code: id=""
Zend_Form_Element::setAttrib( 'id', null ); // results in rendering id="<name
of the element>"
I just simply want to disable the id attribute. Any possibilities?
Cheers
Alle tips en trics. Ontdek nu de nieuwe Windows Live
--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
_________________________________________________________________
De grappigste filmpjes vind je op MSN Video!
http://video.msn.com/video.aspx?mkt=nl-nl