Okay well the date validation seems to be working for me so double check your setup.
I have something like this(widgets/validation): http://paste.turbogears.org/paste/1124 I still don't quite understand what you are saying about passing a member into the form? Does that usually work... like it pulls the data straight from the sqlobject ? Like member.fname goes into the field fname automatically? If so you could try adding magic attributes to the sqlobject that pull the internal fields into a dictionary or something... or into a struct type class so you could achieve the funcionality of: member.contact.fname. Something to this effect. class Member(SQLObject): ... def _get_account(self): return self def _get_contact(self): return self For the most part I just bite the bullet and pass the data in at display time... although it would be nice to have something fancier... it seems like at some point you have to bridge the gap between how you store the data and how you display the data.. and i do that in the controller. Like this(controller): http://paste.turbogears.org/paste/1126 and this(view): http://paste.turbogears.org/paste/1125 If I shouldn't be flooding the paste server with my notes someone tell me. And also tell this guy: http://paste.turbogears.org/paste/1069 Anyways I kind of got carried away with the example but tell me more about how you pass in the form values. -Ian On 3/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > The current piece is for adding and editing a members details. This is > an admin piece to a website. > > It has different sets of information. Their contact information, their > login information, a comment and note section. I use field sets to > break out the different sections. I use validation of each of the > WidgetList subclasses by passing in the validator. I want to use this > same form for adding and editing a user. This was the reason I was > using the fieldSets with the same name, so I could pass in my member > instance as the value for 'fs' in the dict and it would populate all > the form data. When I different names for each fieldset, I have to > pass in my instance for the dict key 'fs1', 'fs2', etc... > > class MemberContactFields(WidgetList): > fname = TextField(label="First Name", > validator=formencode.All(v.NotEmpty(), v.String()) > # more widgets ... lname, suffix, addr1, addr2, state > > class MemberAccountFields(WidgetList): > # more widgets ... login, password, creation date > > I then use a subclass of WidgetList to pull all these together. > > class MemberFormFields(WidgetList): > fs1 = FieldSetAttr(label="Member Contact", legend="Member > Contact", fields=MemberContactFields()) > fs2 = FieldSetAttr(label="Member Account", legend="Member > Account", fields=MemberAccountFields()) > > then I create an instance of MemberForm to pass in to my template. > > memberFields = MemberFormFields() > memberForm = DivForm(fields=memberFields, action="/msave", > submit_text="Save") > > DivForm is a custom widget I created for displaying my forms to give > me more freedom in the style. > > class DivForm(w.Form): > template = """ > <form xmlns:py="http://purl.org/kid/ns#" > name="${name}" > action="${action}" > method="${method}" > class="divform" > py:attrs="form_attrs" > > > <div py:for="field in hidden_fields" > py:replace="field.display(value_for(field), > **params_for(field))" > /> > <div py:attrs="div_attrs"> > <div py:for="i, field in enumerate(fields)"> > <label class="fieldlabel" for="${field.field_id}" > py:content="field.label" /> > <span py:replace="field.display(value_for(field), > **params_for(field))" /> > <div class="break"> </div> > <span py:if="error_for(field)" class="fielderror" > py:content="error_for(field)" /> > <span py:if="field.help_text" class="fieldhelp" > py:content="field.help_text" /> > </div> > <div class="buttonrow" > py:content="submit.display(submit_text)" /> > </div> > </form> > """ > params = ["div_attrs"] > params_doc = {'div_attrs' : 'Extra (X)HTML attributes for the div > tag'} > div_attrs = {} > > On Mar 14, 1:43 am, "Ian Wilson" <[EMAIL PROTECTED]> wrote: > > What are you trying to do ? Application wise... and maybe we can help > > you determine if you are taking the right path. > > > > -Ian > > > > On 3/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > > > > I got it working using a Scheme and the decorator to tell fs1 to use > > > the FS1Schema. When there is an error on the date in my form, the > > > tg_error message is displaying in error div every field of the > > > fieldset when using a schema for the fieldset. Is there a way to only > > > display it for the field and not every field in the fieldset? > > > > > Also, is there an easy way to get my data from a class instance in to > > > my form? Right now I am doing this: > > > form=member_edit(value=dict(fs1=member, fs2=member, fs3=member)) > > > And then to create a new user, I am looking through each fieldset and > > > assigning each value of my member instance manually. There has to be a > > > better way to do both of these? > > > > > I know if you are not using fieldsets, I can just pass in the class > > > instance to the form and it gets populated, also, I can just pass in > > > the form data to the class when I instantiate it. But with the extra > > > fieldset key/value it seems to complicate this. This was the reason > > > for the inital hack of all the fieldsets havnig the same name, so I > > > could just do a formdata['fs'] and have the form data dict. > > > > > Thanks, > > > > > Wayne > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

