-- fire-eyed-...@hotmail.com <fire-eyed-...@hotmail.com> wrote (on Wednesday, 01 April 2009, 12:59 PM +0000): > I wasn't aware of the setElementsBelongTo method. I will look into that.
It was created in large part for this very purpose. A common pattern in PHP is to namespace your forms using array notation, and this was built into Zend_Form. > Are you sure that it will prefix elements with "<name>-" is stead of "<name>_" > (dash instead of underscore?). If so, I believe this is not Javascript > compliant (or at least not cross platform/browser). To my knowledge some (or > maybe all?) Javascript engines have trouble with addressing elements with > dashes in their id's, since a dash is simply a minus sign. > > So I would not be able to do: > document.forms[0].hidden-elements-id. > > I know this maybe a little oldskool, and it would be possible with DOM: > document.getElementById( 'hidden-elements-id' ); Dashes are acceptable in DOM IDs (the HTML specification specifically lists that as a valid ID character). Typical JS usage anymore uses getElementById() -- or, even more typically, proxies to that via library-specific mechanisms; I cannot remember the last time I used document.forms to retrieve form elements, honestly. > But I just thought I'ld bring it up anyway. > > Cheers > > > > Date: Wed, 1 Apr 2009 07:11:22 -0400 > > From: matt...@zend.com > > To: fw-general@lists.zend.com > > Subject: Re: [fw-general] Disable id attribute for form elements? > > > > -- fire-eyed-...@hotmail.com <f ire-eyed-...@hotmail.com> wrote > > (on Wednesday, 01 April 2009, 10:14 AM +0000): > > > Thanks for the response again. I just read in an issue that this is made > > > intentional behaviour: > > > http://framework.zend.com/issues/browse/ZF-277 > > > > > > But I strongly disagree with this. Therefor I created a new issue: > > > > > > http://framework.zend.com/issues/browse/ZF-6174 > > > > I can't get to the issue tracker right now, but I can tell you now that > > I'm going to deny the request. > > > > The reason is two-fold. > > > > First, the design of the form view helpers since the very beginning has > > been to *always* create IDs. This is to make it trivial to get to the > > discrete elements using JavaScript, as well as to make testing easy > > (easier to select DOM elements by ID than other methods, though > > Zend_Dom_Query now makes it less of an issue). > > < BR>> Second, if you're having ID collisions, there is another mechanism > > you > > can use that's built into Zend_Form: array notation. Call the > > setElementsBelongTo() method of your form (or pass the > > 'elementsBelongTo' configuration key) and provide a unique namespace for > > your form. All elements within will then be prefixed by "<name>-". > > > > Refactoring to allow *optional* display of IDs at this point only serves > > an edge case for something that can be easily avoided with proper > > configuration. > > > > > PS.: > > > Vince, my apologies for sending the same message to you twice. I messed up > > > twice with replying to the list in stead of you. > > > > > > > > > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > ━━━ > > > Date: Wed, 1 Apr 2009 11:43:59 + 0300 > > > Subject: Re: [fw-general] Disable id attribute for form elements? > > > From: vadim...@gmail.com > > > To: fire-eyed-...@hotmail.com > > > CC: fw-general@lists.zend.com > > > > > > Hey, > > > > > > Yes, sorry i meant you CAN set null and it should unset the property. I > think > > > it's either a bug or something is wrong or is working not as the way it > should. > > > > > > Not sure but you could raise an issue. > > > > > > Vince. > > > > > > On Wed, Apr 1, 2009 at 11:36 AM, <fire-eyed-...@hotmail.com> wrote: > > > > > > 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 me thod 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: vadim...@gmail.com > > > To: fire-eyed-...@hotmail.com > > > CC: fw-general@lists.zend.com > > > > > > 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, <fire-eyed-...@hotmail.com> 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 > > > n ot 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 > > > > > > > > > > > > > > > -- > > > Vincent Gabriel. > > > Lead Developer, Senior Support. > > > Zend Certified Engineer. > > > > > > > > > > > > > > > > > > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > ━━━ > > > Alle tips en trics. Ontdek nu de nieuwe Windows Live > > > > -- > > Matthew Weier O'Phinney > > Software Architect | matt...@zend.com > > Zend Framework | http://framework.zend.com/ > > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > Heb jij de nieuwe Messenger nog niet?! Download 'm hier -- Matthew Weier O'Phinney Software Architect | matt...@zend.com Zend Framework | http://framework.zend.com/