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
> >
>