On Mar 21, 3:16 pm, Jorge Godoy <[EMAIL PROTECTED]> wrote: > "Gary Doades" <[EMAIL PROTECTED]> writes: > > BTW I just had a peek at the Django newforms widgets (fields). It > > seems they had a similar problem. It looks like it was solved by > > creating the form definition statically (like TG) but at runtime the > > user creates an instance of the form. At instance construction the > > form copies its class field attributes into instance fields attributes > > (self.fields) so that they can be modified at runtime without > > affecting any other form instance. This seems to work for statically > > declaring the form but is efficient and flexible at runtime as the > > form "definition" (the list of widgets etc.) is copied to a mutable > > instance. > > And how they validate that the submitted form is respecting the business rules > for that condition? They rebuild the widget when validating it so that they > can apply the same rules?
Yes, it certainly seems that way as far as I can see. The form needs to be re-constructed at POST time and the POSTed dictionary passed into it for validation. The form instance can then be re-used to display the values plus validation errors if the validation fails. This doesn't seem to take much runtime overhead as the field copy operation is pretty quick. Regards, Gary. > -- > Jorge Godoy <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

