What I meant to say with "I *can* set null as the value" of course is that I
can unset the attribute as per:
if (null === $value) {
unset($this->$name);
...and that I suspect "id" is replaced with "name" if id is unset (which is
basically is the same thing as null IMO)
From: [email protected]
To: [email protected]
Date: Wed, 1 Apr 2009 08:36:47 +0000
Subject: RE: [fw-general] Disable id attribute for form elements?
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.
Haal meer uit je Hotmail met Internet Explorer 8. Download nu
_________________________________________________________________
Krijg updates van je vrienden en blijf op de hoogte
http://home.live.com