On Aug 2, 12:14 am, "Diez B. Roggisch" <[email protected]> wrote:
> Alex King schrieb:
>
>
>
> > Following the instructions at
> >http://www.turbogears.org/2.0/docs/main/ToscaWidgets/forms.html#loadi...,
> > I have my form loading options from the DB.  Great.
>
> > Now I want to have a master/detail form (using tw.dynforms) where each
> > line has a field which needs to load options from the DB.
>
> > eg, in controller:
>
> > class LineForm(dynforms.GrowingTableFieldSet):
> >     class children(core.WidgetsList):
> >         amount = forms.TextField(validator=forms.validators.Number)
> >         etype = forms.SingleSelectField()
>
> > class EntryForm(dynforms.CustomisedForm, forms.TableForm):
> >     action = 'save_entry'
> >     class children(core.WidgetsList):
> >         date = forms.CalendarDatePicker()
> >         description = forms.TextField()
> >         elines = LineForm()
> >         etype = forms.SingleSelectField()
>
> > I successfully pass options to the etype selector in my EntryForm
> > instance from the template:
>
> > ${entryform(child_args=dict(etype=dict(options=topts)))}
>
> > but I can't find how to pass the same options to the etype selector in
> > the LineForm instance...
>
> > Can anyone point me in the right direction?
>
> You need to pass child_args to the elines that contain child_args
> themselves.
>
> I'm not 100% sure because of the GrowingTableFieldSet, but it's either
> directly a dict, or a list with a dict with one entry per row.
>
> So either this
>
> entryform.display(child_args=dict(...,
>             elines=dict(child_args=dict(etype=dict(...)))
> )
>
> or this:
>
> entryform.display(child_args=dict(...,
>             elines=[dict(child_args=dict(etype=dict(...)), ...])
> )
>
> I presume the latter.
>
> Diez

Hmm,

The first results in no error, but the options are not loaded, and the
second a traceback.  (Post traceback didn't seem to work.)  The
traceback ends with:

Module tw.core.util:211 in unflatten_args
>>  for key, val in v.iteritems():
AttributeError: 'list' object has no attribute 'iteritems'

So it looks like it doesn't like a list there.  I guess I need to dig
in to the tw.dynforms code.  I may try to see if I can build by own
repeating widget using standard wt.forms to try to understand this
better.

Thanks,
Alex
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to