Chapter 16.1.2. Render Time Attribute Assignment

Most of the time, if you want to set the value of a form widget that the user will see pre-populated in the form, you want to do it at render time, when you have the data from the database that you want to appear in the widget. We saw this in Chapter 5, where we pulled the bookmark.link and other fields out of the database and assigned the defaults right at render time.

To do this, just drop the values you need into the form widget in your Kid template like this:

${my_form(value=values, action=action)

Assuming you set up a dictionary of values with keys that match the names of the widgets on your forms, this whole thing will just work, and any missing values will either be given the default you ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.