"Baruch Even" <[EMAIL PROTECTED]> writes:
> I've tried just that but couldn't force the value of the HiddenField to
> anything when constructing it, and couldn't find how to set it when displaying
> it. I have the usual: return dict(form=add_form, action="" and inside the
> template ${form(action="" I tried to go over the code to figure
> out how values are set in the fields but didn't quite get it.
> I guess I can change the template of the form to stick it in, but that sounds
> rather ugly.
It is.
When displaying put it in the dict of your form:
data = "" = value1, my_field2 = value2, my_hidden_field =
value)
return dict(form=add_form, action="" data = "">
and then, on your template:
add_form.display(data, action="">
This worked nicely. I needed one more thing, to eliminate the errors on the first display of the form, the solution I got to at the end was to avoid the hidden field and simply give None as the value for the parameters by default. I then check that as follows:
def register(self, username=None, password=None, password2=None):
data = "" password='', password2='')
d = dict(form=form.register, action="" data=""> if username is None:
cherrypy.request.validation_errors = {}
return d
if tg_errors:
return d
The logic is that I reset the passwords if there is a validation error, If the username is None than it's the first time and I reset all validation errors. If there are errors (tg_errors is not false) I return to the form again. Otherwise I continue and handle the registration assuming everything is fine and dandy.
Thanks for your quick response!
Baruch
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

