On Jul 17, 2006, at 10:09 PM, jerojasro wrote:

>
>
> Alberto Valverde wrote:
>> You should be abe to do something like:
>>
>> w = MultipleSelectField("mselect", validator=Int(not_empty=True))
>> ...
>> You can provide a failsafe value fo this scenario by
>> passing it to the validator as the 'if_empty' parameter:
>>
>> w = MultipleSelectField("mselect", validator=Int(if_empty=2))
>>
> nope, It doesn't work. My code:
>
> f=w.TableForm(fields=[
>
> w.MultipleSelectField(name="opt",label="Options",size=5,options= 
> [(i,str(i))
> for i in range(5) ],validator=v.Int(not_empty=True,if_empty=-45))
>     ],
>     submit_text=u"Push Me!!")
>
> class Root(tg.controllers.RootController):
>
>   @tg.expose(template="forms.templates.forms")
>   def index(self):
>     global f
>     return dict(form=f,title=u"Hello!!!",action="put")
>
>   @tg.expose(format="json")
>   @tg.validate(form=f)
>   @tg.error_handler(index)
>   def put(self,**kwargs):
>     return kwargs
>
> If I don't select anything, I get an empty list. If I select  
> something,
> I get a list of integers. I've tried too using only if_empty, and too
> using only not_empty, with the same results.

FYI, I've comitted at 1651 in the 1.0 branch a fix for this. More  
info at http://trac.turbogears.org/turbogears/ticket/1033/ and at the  
attached app.

HTH,
Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to