#659: SelectionFields with Int validators don't like no values
----------------------+-----------------------------------------------------
 Reporter:  xentac    |       Owner:  anonymous
     Type:  defect    |      Status:  new      
 Priority:  normal    |   Milestone:           
Component:  Widgets   |     Version:           
 Severity:  critical  |    Keywords:           
----------------------+-----------------------------------------------------
 If you create a CheckBoxList that uses a Int validator (by making sure all
 the options you pass in have integer values), you'll get an error trying
 to
 submit a form with nothing checked.

 Apparently, formencode's ForEach has convert_to_list set, so a blank
 string
 is converted to [''], and then '' is passed to the int validator and it
 doesn't accept it.

 I couldn't find an unugly or straigtforward way to fix this... I ended up
 creating my own validator like this:

 self.validator = formencode.ForEach(convert_to_list=False, if_empty=[])
 self.validator.validators = [validators.Int()]

 The problem with this is that if there is nothing checked, the variable
 passed to my method (**data, because I'm using the fast data controller)
 on
 form submit, doesn't exist.

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/659>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to