First usually form fields are set when you instantiate the form.  Like this
querySetForm = ListForm(
   fields = [
       TextField(name="foo",
validator=validators.String(not_empty=True, max=16)),
       FieldSet(fields=[
           TextField(name="bar",
                         validator=validators.String(not_empty=True,
max=16))])

Also I think the validator is not getting attached properly because
the field set needs a name.  This should probably cause some sort of
error so maybe that is a bug.

So overall your example should look something like this:
querySetForm = ListForm(
   fields = [
       TextField(name="foo",
validator=validators.String(not_empty=True, max=16)),
       FieldSet(name = "barwrapper", fields=[
           TextField(name="bar",
                         validator=validators.String(not_empty=True,
max=16))])

To take it even further I've found that using widgets.WidgetsList and
validators.Schema make my forms easier to use and debug.  So ,although
slightly overkill and wordy, this is the fanciest way to do it:

#Schemas
class BarWrapperSchema(Schema):
    bar = String(not_empty=True, max=16)

class QuerySetSchema(Schema):
    foo = String(not_empty=True, max=16)
    barwrapper = BarWrapperSchema()

#Widgets
class BarWrapperFields(WidgetsList):
    bar = TextField()

class QuerySetFields(WidgetsList):
    foo = TextField()
    barwrapper = FieldSet(fields = BarWrapperFields())

#Form
querySetForm = ListForm(fields=QuerySetFields(), validator=QuerySetSchema())

Tell me if this doesn't make sense or still isn't working for you.

-Ian

On 3/26/07, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> On Mar 23, 2:24 am, "Ian Wilson" <[EMAIL PROTECTED]> wrote:
>
> > The short answer is you don't really need anything special but its
> > hard to tell from the details provided.  Can you give your form
> > declaration ? And your corresponding validation.. or I guess that
> > would be in the form declaration in your case.
> >
> > -Ian
> >
> > On 3/22/07, George Sakkis <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I'm trying to set up a form with a fieldset that has a bunch of
> > > widgets. The generated html uses dotted names for the inputs such as
> > > name="widget.description" etc. Now when I submit the form and just
> > > return the **kwds without a template, I get a nested dict like
> > > {"widget": {"description": "", "name": "", "queries": ""}}
> >
> > > The thing is that some of the nested fields have validators but they
> > > don't seem to apply. If I don't use the fieldset and attach the fields
> > > directly to the form, validation works fine. Is there anything special
> > > I should do to activate validation on nested widgets ?
> >
> > > George
>
>
> Here's a minimal example:
>
> class QuerySetForm(ListForm):
>     fields = [
>         TextField(name="foo",
> validator=validators.String(not_empty=True, max=16)),
>         FieldSet(fields=[
>             TextField(name="bar",
>                           validator=validators.String(not_empty=True,
> max=16))]),
>     ]
>
>
> The generated html has "requiredfield" class only for the "foo"
> widget, not "bar". Is this a bug or what ?
>
> George
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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