> only deals with SingleSelectField options and doesn't even talk about
setting
> the correct select value by default. I spent hours trying to set default
properties of all of the widgets in my template in every way I could
think
> of,
> but alas this 'exercise for the reader' is beyond my comprehension at
the
> moment. Reading tw source didn't help me understand the process either.
If
To do this is reasonably straightforward.
First create your form, as described in the docs you referred to already.
Then, in your controller you need to instantiate an object that contains
the data you want to pre-fill with. Here's a simple example (showing how
you might get an existing user's record from the database):
edit_user_form = UserForm("edit_user_form", action="updateuser")
@expose("myapp.templates.user_form")
def edituser(self, **kw):
"""Page showing a form to edit an existing user"""
# get user record from database
user_id = kw['user_id']
my_user = DBSession.query(User).filter_by(id=user_id).one()
# set up a form in the template's context
pylons.c.form = edit_user_form
# return all the data you want in the template
return dict(my_user=my_user)
Then, in your template (templates/user_form.html) you need to do something
like this:
${tmpl_context.form(my_user)}
bo.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---