Leandro Lucarella a écrit : > Hi! I want to set the options of a MultipleSelectField at 'display time' > but I couldn't find how to do it. > > I have something like this: > > form = TableForm(fields=[MultipleSelectField(name='stuff', ...), ...], ...) > > And I want to do something like: > form.display(stuff_options=[(x, x) for x in object.my_xs]) > > The important thing is I can't use a simple callable and set the options > at 'creation time' because the 'object' changes from request to request. > > I had a similar issue with a RadioButtonList where I wanted to setup the options at render time. What I did is subclassing the RadioButtonList widget and only change the template replacing options by dyn_options. Then at render time (and creation time) I use dyn_options instead of options. If I understood what happens, options is filtered by the widgets mechanism at render time. Any other name is not, so it works. I think this method can be duplicated to your case and then you'll make calls like
form = TableForm(fields=[MyMultipleSelectField(name='stuff', ...), ...], ...) form.display(dyn_options=dict(stuff=[(x, x)..... > Any ideas are welcome (besides instantiating the TableForm on each > request, that should work but I'd like a better solution, if it exists). > > TIA. > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

