On Jul 17, 2006, at 10:17 AM, [EMAIL PROTECTED] wrote:

>
> For those who've had similar problem, the solution, or the bug I've
> found is:
>
> articles   = widgets.SingleSelectField(label=Articles',
> validator = validators.MinLength(0),
>         options    = get_options)
> ...more widgets and put them in a TableForm
>
> def get_options():
>     articles = model.Article.select()
>     opt = [(a.id, a.name) for a in articles]
>     return opt
>
> part from kid template:
> ${form.display(value=data)}
>
> where data is something like data['articles'] = just_calculated_value.

Just to make sure you haven't overlooked this,  
'just_calculated_value' should be of type 'int' in your case (the  
option for the select field, not the (option, label) tuple)

>
> This default value would not work unless I remove the validator from
> the SingleSelectField. I don't know if this is normal, but it lost me
> an hour... I had put the validator because I was getting an exception
> that no default validator is found, but later after removing the
> validator it didn't complain, I suppose I have changed the options for
> this field...

The select fields (multiple and single) need a validator if no  
options are specified when initialized because it has no way of  
guessing one otherwise. I usually don't like this guessing so I  
always provide a validator when defining them.

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