On Feb 27, 8:34 pm, Jim Steil <[EMAIL PROTECTED]> wrote:
[snip]
> But, then I wouldn't know how to specify it on my field def.  Here is
> what I do for the non-filtered dropdown:
>
> plant = SingleSelectField(label='Plant:',
> options=qlfOptions.getUserPlantOptions)
>
> I don't know where I'd supply the parameter.  Would I do it somehow in
> the controller?

Yes, in the controller:

user_plant_widget = SingleSelectField('plants', options=[]) # put
default/dummy options in

@expose('project.templates.user_plant'
def plant(self, user):
    options = qlfOptions.getUserPlantOptions(user)
    return dict(widget=user_plant_widget,
params=dict(options=options))

And somewhere in user_plant.kid:

...
${widget.display(**params)}
...

That will pass the options in when the page is rendered for the given
user.

If your SingleSelectField is part of a form or other compound widget,
you'll need to pass the options differently. I can't remember the
syntax exactly for TG widgets, but for ToscaWidgets I think it would
be (untested, from memory)

@expose('project.templates.user_plant'
def plant(self, user):
    options = qlfOptions.getUserPlantOptions(user)
    child_args = dict(plants=dict(options=options)) # child named
'plants' gets the keyword argument 'options'
    return dict(widget=user_plant_widget,
params=dict(child_args=child_args))

The pattern for TG widgets is similar, but it's not "child_args", its
something else, and I think the structure might be different.
Sorry, can't remember any docs on it, I had to grok the source to
figure it out back then. I've been using toscawidgets since they were
released, much better IMO.

HTH

--
wavy davy



   return dict(widget=



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to