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