[Zope3-dev] Re: browser widgets: items widgets and label tags

yuppie y.2006_ at wcm-solutions.de
Fri Nov 10 05:40:19 EST 2006


Hi!


I found a simpler solution:

yuppie wrote:
> 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">&nbsp;spam</label>
>     <br>
>     <label><input id="WIDGET_NAME.1" name="WIDGET_NAME"
>            value="ham" type="checkbox">&nbsp;ham</label>
>     <br>
>     <label><input id="WIDGET_NAME.2" name="WIDGET_NAME"
>            value="eggs" type="checkbox">&nbsp;eggs</label>
>   </div>

While pointing the label to the div element that contains the input 
fields is not very useful, this seems to be valid HTML::

   <label for="WIDGET_NAME">WIDGET_LABEL</label>
   <div class="value" id="WIDGET_NAME">
     <label><input id="WIDGET_NAME.0" name="WIDGET_NAME"
            value="spam" type="checkbox">&nbsp;spam</label>
     <br>
     <label><input id="WIDGET_NAME.1" name="WIDGET_NAME"
            value="ham" type="checkbox">&nbsp;ham</label>
     <br>
     <label><input id="WIDGET_NAME.2" name="WIDGET_NAME"
            value="eggs" type="checkbox">&nbsp;eggs</label>
   </div>

Making sure that radio and checkbox widgets have a div tag with the 
required ID is a simple bugfix. No API changes are required and 
zope.formlib still can use the widget name in the 'for' attribute.


So IBrowserWidget's __call__ method *has to* return a snipped that 
contains a tag with the widget's name as ID. All widgets that don't 
follow that rule have to be fixed.

If there are no objections, I'll make the required changes on 3.2 
branch, 3.3 branch and trunk.


Cheers,

	Yuppie



More information about the Zope3-dev mailing list