vandevel schrieb:
> I have a few forms that have several fields in common however, the
> order of those fields does differ. In an attempt to avoid redundant
> field declarations, I declared the fields at module level and simply
> referenced the ones that pertained to each field list e.g.:
>
> field_a = TextField()
> field_b = TextField()
> field_c = TextField()
> field_d = TextField()
>
>
> class FieldListA(Widget)
> field_a = field_a
> field_b = field_b
> field_c = field_c
>
> class FieldListB(Widget)
> field_c = field_c
> field_b = field_b
> field_a = field_a
>
> class FieldListC(Widget)
> field_d = field_d
> field_c = field_c
> field_b = field_b
>
>
> This actually worked, but resulted in some funky behaviour such that
> the fields did not display in the declared order when the form was
> rendered. I imagine there must be a sensible way to achieve my goal
> and any advice would be appreciated.
The order is some magic that works through a global counter. I guess
that get's messed up in your somewhat unusal pattern.
You can achieve what you want like this:
field_a = lambda: TextField()
...
Then do
class FieldListB(WidgetsList):
field_a = field_a()
Diez
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---