On 1/6/06, Jeremy Jones <[EMAIL PROTECTED]> wrote:
> I have a TableForm with a bunch of TextFields (and other stuff...). I'm
> trying to use it as the C and U prongs of the CRUD pitchfork. I've got
> create working well. But how do I instantiate the TableForm and pass
> it, say, a dict, and have it update the TextFields (and other stuff...)
> with the data in the dict? this_table_form.input(some_dict) didn't
> work. this_table_form.insert(input_values=some_dict) didn't work,
> either. I tried mucking about in the fastdata source, but couldn't
> figure out how it's being done there. Any tips would be greatly
> appreciated.
Widgets by default work thusly:
top_form = TableForm(name="top_form", widgets=(
TextField(name="alpha"),
TextField(name="bravo"),
TextField(name="charlie"))
...in an exposed method...
return dict(
data = {'alpha':1,'bravo':2,'charlie':3},
form = top_form,
)
...in your template...
${form.insert(data)}
The data is expected to be a class with attributes matching the names
in the form, but if you pass in a dict with the correct keys it gets
converted. The names in the data and on the text fields have to match.