[Zope3-Users] z3c.form: hidden select widget id attribute

Markus Kemmerling markus.kemmerling at meduniwien.ac.at
Wed Aug 20 03:28:57 EDT 2008


Hi,

there is a small issue with the template for a hidden select field  
widget, select_hidden.pt, in z3c.form.  It renders an input tag with  
the same id as the *option* tag with the selected value in input mode  
instead of the id of the *select* tag in input mode. I consider this  
a mistake, since it makes the id depend on the selected value. The  
hidden input tags represents the select field itself, not one of it's  
items.

This probably sounds complicated, but is easy to see by closely  
looking at the relevant parts in select.txt:

Input mode (id="widget-id"):

   >>> print widget.render()
   <select id="widget-id" name="widget.name:list"
           class="select-widget" size="1">
   <option id="widget-id-novalue" value="--NOVALUE--"
           selected="selected">select a value ...</option>
   <option id="widget-id-0" value="a">a</option>
   <option id="widget-id-1" value="b">b</option>
   <option id="widget-id-2" value="c">c</option>
   </select>
   <input name="widget.name-empty-marker" type="hidden"
          value="1" />

Hidden mode (id="widget-id-1"):

   >>> print widget.render()
   <input type="hidden" name="widget.name:list"
          class="hidden-widget" value="b" id="widget-id-1" />
   <input name="widget.name-empty-marker" type="hidden"
          value="1" />

The fix is so trivial that I almost hesitate to state it:

--- /Users/markus/eggs/z3c.form-1.8.2-py2.4.egg/z3c/form/browser/ 
select_hidden.pt       2008-08-19 20:33:32.000000000 +0200
+++ select_hidden.pt    2008-08-20 09:19:24.000000000 +0200
@@ -3,7 +3,7 @@
             repeat="item view/items">
    <input type="hidden" name="" class="hidden-widget"
           tal:condition="item/selected"
-         tal:attributes="name name; value item/value; id item/id" />
+         tal:attributes="name name; value item/value; id id" />
  </tal:block>
  <input name="field-empty-marker" type="hidden" value="1"
         tal:attributes="name string:${view/name}-empty-marker" />

Regards,

Markus Kemmerling


More information about the Zope3-users mailing list