Commits

Anonymous committed 421c0f4

use modernized select options approach

  • Participants
  • Parent commits 99fcd1f

Comments (0)

Files changed (2)

File formhelpers/controllers/comment.py

 import formencode
 
 HEARD_CHOICES = [
-    ('the internet', 'internet'),
-    ('from a friend', 'friend'),
-    ('on the radio (really?)', 'radio'),
+    ('internet', 'the internet'),
+    ('friend', 'from a friend'),
+    ('radio', 'on the radio (really?)'),
 ]
 
 class CommentForm(formencode.Schema):
     allow_extra_fields = True
     filter_extra_fields = True
     name = formencode.validators.String(not_empty=True)
-    heard = formencode.validators.OneOf([c[1] for c in HEARD_CHOICES], not_empty=True)
+    heard = formencode.validators.OneOf([c[0] for c in HEARD_CHOICES], not_empty=True)
     comment = formencode.validators.String(not_empty=True)
 
 class CommentController(BaseController):

File formhelpers/templates/comment_form.html

     <tr>
         <td>How did you hear about this site ?</td>
         <td>
-            <%form:select name="heard">
+            <%form:select name="heard" options="${c.heard_choices}">
                 <%form:option value="">None</%form:option>
-                % for desc, value in c.heard_choices:
-                    <%form:option value="${value}">${desc}</%form:option>
-                % endfor
             </%form:select>
         </td>
     </tr>