I have a concrete example here. I'm making a calendar that lets you specify custom recurrences. Things like "Every monday and wednesday" or "The third wednesday of every month". I represent these recurrences using the ical recurrence specification (http://www.kanzaki.com/docs/ical/recur.html). It's a single db field that stores a string.
Needless to say, this interface is fairly complex, with many form fields. I have two options from what I can tell: 1) write a single widget that contains multiple form fields and an update_data function to parse the string into the form values 2) write a compound widget that contains all the other form fields as widgets Solution 1 makes things easy rendering the widget. I just stick the db column into the value dictionary with the widget's name as the key. The widget parses everything into the proper fields and Bob is, as they say, my uncle. Coming back to the controller though, the validator will try and find a form field with that widget's name and barf. I'd have to create a validator with allow_extra_fields, etc in it. Then the controller would have to piece the data back together into a new string that represented the new recurrence. Solution 2 makes things easy for validation. All the fields are accounted for and validated properly. It makes the controller slightly more complicated, because the controller has to parse the recurrence string instead of the widget doing that. The controller, on the way in, would be the same level of complication, because it would have to do the same recreation. Ideally, I think, you'd want a widget that you could give a recurrence string to on the controller end and get a recurrence string out when it's submitted back. With all the fields validated properly and errors displayed next to the proper fields. It's almost like a compound widget that can take a string as its value instead of a dictionary. Is there some way I can do this? Jason -- If you understand, things are just as they are. If you do not understand, things are just as they are.
pgpfpSLCMz1W3.pgp
Description: PGP signature
