On 2/11/07, iain duncan <[EMAIL PROTECTED]> wrote: > > On Sun, 2007-11-02 at 13:42 -0800, miya wrote: > > For example, suppose a User has some pets (say 'dog', 'cat', > > 'giraffe', 'alligator', 'anaconda', etc...), and in the form I need to > > pre-select tha animals/pets that some dude has. The question is how do > > I pass the user's id to myCallable? > > if your using identity you just need to call the current identify from inside myCallable. identity.current will return a User instance, so something like Pets.selectBy(owner=identity.current) should work.
> > How do I do this? > > > > def formExample(widgets.WidgetsList): > > ... > > ... > > pets = widgets.MultipleSelectField( > > label = '', > > name = 'pets', > > options = getAllPets, > > size = 5, > > default = myCallable?? > > ) by the way size 5 is the default :p > > I was about to post almost the same question! Except I can't even get > anything pre-selected with or without the callable. Even when I try > sorry to point you to the source code http://trac.turbogears.org/browser/tags/1.0.1/turbogears/widgets/forms.py#L968 you can also check it out on your toolbox under the widget browser. Check out the MultipleSelectFieldDesc and the template under MultipleSelectField > widgets.MultipleSelectField("sizes", label="Sizes", options=get_sizes, > default=[1,2,3], validator=validators.NotEmpty ), > as you can see from above get_sizes and getAllPets must return a list of tuples where each tuple is (value, desc, attrs) and attrs is optional. you just need to be sure value in options is the same object as each key in default. if this is the case please post your get_sizes/getAllPets functions, so we can see what's wrong. > or as above with default=['1','2','3'] > > nothing winds up being preselected. Which is weird 'cause it sure looks > like it matches the code in the toolbox. Does the callable for options > hose the preselection? Any good plans for working around this? > > Thanks > Iain --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---

