Hello,
Using your naming scheme, the following should would. I just tested it.
@expose(template="tester.templates.evenprimes")
def evenprimes(self):
#Root
formData = {}
#Go into the form
formData['value'] = {}
#Go into the field set name
formData['value']['name'] = {}
#Set name.status to "Present, not correct"
formData['value']['name']['status'] = 1
#Set the data found, 7
formData['value']['name']['found'] = '7'
#Set the data we wanted, an even prime, 2
formData['value']['name']['correct'] = '2'
return dict(form=form, formData=formData)
<?python
#AND IN YOUR TEMPLATE evenprimes.kid
?>
${form(value=formData['value'])}
Reply if anything is unclear, or if it just doesn't work.
-Ian
On 9/21/06, Chris <[EMAIL PROTECTED]> wrote:
>
> I'm building a test tracking app. When tests fail, there are 13 data
> elements that have to be researched to identify the source of the
> error. I've defined my forms and to make things clear for the user
> (and less code for me) I've defined a TranslationErrorType to replicate
> for each of the errors. However, when I need to populate the data
> elements in the FieldSets I can't figure out how to define my
> parameters to the values options.
>
> Below is a small sample that seems to show the problem:
>
> ###### How the form fields are defined
> error_options = [(0, 'Present, correct'),
> (1, 'Present, not correct'),
> (2, 'Missing'),
> (3, 'Not Applicable')]
>
> class TranslateErrorType(widgets.WidgetsList):
> """"""
> status = widgets.SingleSelectField(options=error_options,
> default=0)
> found = widgets.TextField(label='Data Found:',
> validator=validators.String())
> correct = widgets.TextField(label='Correct Data:',
> validator=validators.String())
>
>
> class ClaimFormFields(widgets.WidgetsList):
> """Fields to enter a "bad" claim"""
> tf = widgets.SingleSelectField(options=error_options, default=0)
> name = widgets.FieldSet(legend='Name', fields=TranslateErrorType())
> addr = widgets.FieldSet(legend='Address',
> fields=TranslateErrorType())
>
> # After defining a TableForm I try to populate the data elements like
> this:
> vals = dict(name_status=2, tf=2)
>
> claim_form.display(value=vals))
>
> # The tf field changes just fine. How to I access that "nested" status
> field for the name though? Thanks!
>
> Chris
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---