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.
> Validators for compound widgets should subclass
> turbogears.validators.Schema. If you don't define one for the
> compound widget itself then a schema will be automatically generated
> including every validator present in the child widgets. If this is
> not working for you, can you please submit some code that presents
> this behavior? Maybe you've found a bug or maybe you're just doing
> something wrong... ;)
when I can get the multiple select working I'll be checking this. But
now is much more clear
> Alberto
Javier
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---