On Mon, 2008-07-07 at 09:09 -0700, Eoghan wrote: > > I know this has been touched on before; > http://groups.google.com/group/turbogears/browse_thread/thread/69d79f7fd7be79f0/bf395a5c6721da91 > > I'm looking for a way to edit the label text in a widget from a > controller, e.g. something like the following pseudo code: > > @expose() > def myform(self, **kwargs): > if some_condition: > my_list_form.myfield.label += " Some extra text" > return dict(my_list_form=my_list_form) > > I've tried something like this and have gotten ValueError: It is not > threadsafe to modify widgets in a request > > At the moment it's looking a lot easier to skip the widgets and put > the html for the form directly in my template in conjunction with a > FormEncode validator..
I would recommend very strongly against that, myself. The widgets are difficult to learn, and I've pulled many hairs out over them, but once you get it they are fantastically powerful. For the above, you actually have a few options. I'd recommend you make your own widget class that subclasses list_form, and then you can either: - change the template to do what you want - override update_params in the widget to change the field.label_text for the field in question Or you could make a new field widget that subclasses your field and alter it there. I'm doing both in my case. It seems like a bit of a headache at first, but making your own derived widgets opens up a lot of handy options. There are some good examples coming up on the TosaWidgets site now too. my two cents! 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 -~----------~----~----~----~------~----~------~--~---

