jthibeaux
unread,Jul 24, 2008, 1:26:53 PM7/24/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TurboGears
While I have managed to get what I want to do to work, I am not
particularly satisfied with the solution cause I am convinced that
this isn't an elegant way to go about things. That is, it feels like
a hack.
The simple problem is I have a query form that is re-displayed with
the results of the query. I would like to retain the values the user
submitted in the form; however, one of the fields, if it is empty, I
want to change the value to a hint string like "type in X here."
On first glance, I thought I could use the adjust_value method on the
form to check if the current value for that field is empty, and, if
so, set "type in X here"; however, this adjustment promptly gets
ignored during page rendering.
The reason why seems to be in the code for InputWidget:
def adjust_value(self, value, **params):
if hasattr(request, "input_values") and self.is_validated:
input_submitted = True
iv = retrieve_value_by_path(request.input_values,
self.name_path)
This seems to be subverting whatever value assignment I make for the
form to use cherrypy.request.input_values instead.
Now, my workaround is simply to set
cherrypy.request.input_values['field'] = "type in X here" when
adjusting the values. Is there no other way to force a value
adjustment that will also override user input?
Jeremy