Hi!
I plan to do some bugfixing in zope.formlib and zope.app.form. This is
what I'd like to fix first:
The HTML label tag is not used correctly with items widgets. The result
is invalid HTML. This is how a MultiCheckBoxWidget is basically rendered::
<label for="WIDGET_NAME">WIDGET_LABEL</label>
<div class="value">
<input id="WIDGET_NAME.0" name="WIDGET_NAME"
value="spam" type="checkbox"> spam
<br>
<input id="WIDGET_NAME.1" name="WIDGET_NAME"
value="ham" type="checkbox"> ham
<br>
<input id="WIDGET_NAME.2" name="WIDGET_NAME"
value="eggs" type="checkbox"> eggs
</div>
The 'for' attribute is invalid because its value is the *name* of the
widget, not an ID of an input field.
Pointing the label to a specific input field would not be very useful.
AFAICS the widget's label tag should have no 'for' attribute at all.
Instead, each value text should be a label. Something like this::
<label>WIDGET_LABEL</label>
<div class="value">
<label><input id="WIDGET_NAME.0" name="WIDGET_NAME"
value="spam" type="checkbox"> spam</label>
<br>
<label><input id="WIDGET_NAME.1" name="WIDGET_NAME"
value="ham" type="checkbox"> ham</label>
<br>
<label><input id="WIDGET_NAME.2" name="WIDGET_NAME"
value="eggs" type="checkbox"> eggs</label>
</div>
The widget's label tag is created by the form template, not by the
widget. ISimpleInputWidget doesn't seem to have an attribute that is
useful for creating a label tag. zope.formlib uses IWidget's name
attribute, but as the example above shows it is not always useful.
So I propose to add a 'controlID' attribute (or something similar)::
controlID = TextLine(
title=u'Control ID',
description=u'ID used for binding the widget label.',
required=False)
In most cases this would have the same value as 'name', but for
MultiCheckBoxWidget and other item widgets this could be set to None or
the ID of a specific control element.
Does that make sense? Am I missing something?
This is a bugfix, but also a significant change. Is it fine to fix this
on the Zope 3.2 and 3.3 branches?
Cheers,
Yuppie
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com