Say I define something like this at the top level of controllers.py:
class CommentFields(widgets.WidgetsList):
name = widgets.TextField(validator=NotEmpty())
url = widgets.TextField(validator=NotEmpty())
post_id = widgets.HiddenField()
email = widgets.TextField(validator=Email(not_empty=True),
attrs={'size':30})
text = widgets.TextArea(validator=NotEmpty())
remember = widgets.CheckBox(label="Remember me")
comment_form = widgets.TableForm(fields=CommentFields(),
action="comment")
Now, in a controller method, I want to get hold of the post_id field
and set the value of the hidden form field to the current post_id (which
is only known at the time the controller method runs). At the moment,
I'm doing this by defining the CommentFields class inline in the controller
method, and setting the value at the time the class is defined, but
a) this seems inelegant
b) it means the CommentFields class isn't available to use as a validator
in the controller's comment() method (the target of the form).
I could always dig through the class object and set the post_id, but that
strikes me as cruising for a bruising, since it's a single class object.
I've hunted around for information on this, to no avail. I even tried
reading tg.widgets.form and now my eyes are bleeding but I still don't
know the answer.
Maybe I'm just missing an obvious source of answers...
Thanks,
Anthony
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---