Sorry I thought you were trying to change the id on the form element. I should have read closer. You can do this with form decorators. You should be able to add a decorator to the elements that changes the id attribute I think. Decorators are kind of tricky.
Fred On Wed, Sep 30, 2009 at 2:51 PM, Eugene Morgan <[email protected] > wrote: > Thanks for the tip, but it doesn't quite do what I'm looking for ... > it looks like the id attributes of the <dd> and <dt> tags are > generated based on the element's name rather than its id. So when I > manually change the element's id the <dd> and <dt> id's are not > affected. > > On Wed, Sep 30, 2009 at 11:28 AM, Fred Jiles <[email protected]> wrote: > > Can you possible use the setAttribute method to set the id manually? > > > > $element->setAttrib('id', 'instance1_text') > > > > Just append the id with something. > > Fred > > On Wed, Sep 30, 2009 at 12:01 PM, Jonathan Maron > > <[email protected]> wrote: > >> > >> Hello Eugene and others > >> > >> I have a similar issue when I place multiple navigation elements > >> (Zend_Navigation) on to one page. Also in this case, I get multiple id > >> attributes that are identical, which lead to invalid XHTML 1.0 Strict. > >> > >> Up to now, I have not found a good solution to this issue. > >> > >> However, I did have one really 'hack' solution... > >> > >> I wrote a simple Zend_Controller_Plugin to search and replace the > >> multiple IDs in the generated XHTML. The plugin is triggered at > >> dispatch loop shutdown. > >> > >> This is, of course, a very unsatisfying solution, but it works. > >> > >> Maybe you could take a similar approach, or someone else could say how > >> to avoid multiple identical id attributes in the first place. > >> > >> Thanks :-) > >> > >> Jonathan > >> > >> > >> > >> On Wed, Sep 30, 2009 at 5:19 PM, Eugene Morgan > >> <[email protected]> wrote: > >> > I have a page that can potentially have multiple instances of the same > >> > form. I know I can use setElementsBelongTo() to prevent having more > >> > than one form element with the same name. But is there any similar way > >> > to prevent the dt and dd tags from getting assigned the same id > >> > attributes over and over again? > >> > > >> > For example: > >> > > >> > Form 1: > >> > $instance1->setElementsBelongTo('instance1'); > >> > ... > >> > <form ...> > >> > <dl> > >> > <dt id="element1-label"> > >> > <label class="optional" for="instance1-element1">Some > >> > label</label> > >> > </dt> > >> > <dd id="element1-element"> > >> > <input type="text" name="instance1[element1]" ... /> > >> > </dd> > >> > </dl> > >> > </form> > >> > > >> > Form 2: > >> > $instance2->setElementsBelongTo('instance2'); > >> > ... > >> > <form ...> > >> > <dl> > >> > <dt id="element1-label"> // Same id duplicated from instance > 1 > >> > ... > >> > <input name="instance2[element1]" ... /> // But name > >> > changes > >> > > > > > >
