2009年4月3日星期五

[fw-mvc] Fw_Form: Invalid XHTML with "multi" elements

Hello,

I have a form that is generating invalid XHTML when using "multi" elements (radio, multiCheckbox, etc.). The problem is the label tag has a "for" attribute that points to an id that doesn't exist:

<dt><label for="subjects" class="optional">Subjects</label></dt>
<dd><label for="subjects-1"><input type="checkbox" name="subjects[]" id="subjects-1" value="1" />English</label></dd>
<dd><label for="subjects-2"><input type="checkbox" name="subjects[]" id="subjects-2" value="2" />Math</label></dd>

Is there a way to remove the "for" attribute in the label decorator? Or, better yet, is there a way to remove the label tag (while keeping the text) or change it to a span or div?

I've tried modifying the decorator but these didn't work:

$label = $form->subjects->getDecorator('label');
$label->setOption('for', null); // adds a second "for" attribute to the label tag, set to ""
$label->removeOption('for'); // no change
$label->setTag('span'); // this wraps a span around the label tag

Any suggestions on how to remove the offending "for" attribute?  I am using the 1.7.8 tag of ZF. Thanks!

-Hector

没有评论: