"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="/add") and inside the
> template ${form(action=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 = dict(my_field_1 = value1, my_field2 = value2, my_hidden_field =
                 value)
     return dict(form=add_form, action="/add", data = data)

and then, on your template:

     add_form.display(data, action=action)

> Also, The method when called for the first time to display the form
> immediately tries to validate the fields (default values) and they obviously
> fail adding the messages to the field on first display.

You can pass an empty dict the first time.  Widgets are smart enough to use
their default value if they receive nothing specific (for most widgets the
default is nothing at all).


-- 
Jorge Godoy      <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to