Say you have some Widget like this:
form = Form('FormName',
children=[
FieldSet('FieldSetName',
children=[
TextField('TextFieldName')])
])
and displayed in your template like this:
${ form.display(**form_args)}
then you can pass values into it from your controller like so:
def controller(self):
return dict(form=form,
form_args={'value':{
'FieldSetName':{ 'TextFieldName':
'Desired TextField Value'}}})
I guess it's pretty obvious in retrospect, in fact, the compound Form outputs something much like this (minus the outside dictionary), and those values can be passed right back into the Compound Form again. Perhaps, had I been actually using a Model, or gotten more sleep, this all would have been more natural - but hopefully this helps someone else.
Hint: If you're overriding templates, be sure that you're still passing the right values in to fetch the children arguments, i.e.:
${section.display(value_for(section), **args_for(section))}
No comments:
Post a Comment