Hi Ed, there is a problem in your template, you shouldn't access the field or your fieldset directly but let the fieldset display them otherwise the field will not result as nested once displayed.
I'm trying to understand what you want to do, I will send here another template. Ciao Michele Ed Singleton wrote: > After a little investigation, my form with multiple fieldsets returns > a nested dictionary when it is submitted, whereas the table form with > multiple fieldsets returns a flat dictionary. > > Interesting. > > Ed > > On 08/05/06, Ed Singleton <[EMAIL PROTECTED]> wrote: > > Well, the form now works fine with values being passed in like there's > > no tomorrow. > > > > However the multi fieldset table form I wrote, only seems to accept a > > flat list of values, rather than a nested list, which is nice in some > > ways, but it's annoying that it is different to the other form. > > > > from turbogears.widgets import * > > > > class MultiFieldSetTable(TableForm): > > template = """ > > <form xmlns:py="http://purl.org/kid/ns#" > > name="${name}" > > action="${action}" > > method="${method}" > > class="tableform" > > py:attrs="form_attrs" > > > > > <table py:attrs="table_attrs"> > > <tbody py:for="fieldset in fieldsets" py:strip="True"> > > <tr py:if="fieldset.legend"> > > <td colspan="2"> > > <h1 py:content="fieldset.legend">This is a > > Heading</h1> > > <div py:for="field in hidden_fields" > > py:replace="field.display(value_for(field), > > **params_for(field))" > > /> > > </td> > > </tr> > > <tr py:for="i, field in enumerate(fieldset.fields)" > > class="${i%2 and 'odd' or 'even'}" > > > > > <td> > > <label class="fieldlabel" > > for="${field.field_id}" py:content="field.label" /> > > </td> > > <td> > > <span > > py:replace="field.display(value_for(field), **params_for(field))" /> > > <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" /> > > </td> > > </tr> > > </tbody> > > </table> > > </form> > > """ > > member_widgets = ["fieldsets"] > > fieldsets = [] > > > > class FS1(WidgetsList): > > f1 = TextField() > > > > class FS2(WidgetsList): > > f2 = TextField() > > > > class MyForm(WidgetsList): > > fs1 = FieldSet(fields=FS1()) > > fs2 = FieldSet(fields=FS2()) > > > > myform = MultiFieldSetTable(fieldsets=(MyForm())) > > > > nestedvalues = dict(fs1=dict(f1="one"),fs2=dict(f2="two")) > > flatvalues = dict(f1="one",f2="two") > > > > assert "one" in myform.render(value=nestedvalues) > > assert "two" in myform.render(value=nestedvalues) > > assert "one" in myform.render(value=flatvalues) > > assert "two" in myform.render(value=flatvalues) > > > > Gives me: > > > > >>> assert "one" in myform.render(value=nestedvalues) > > Traceback (most recent call last): > > File "<console>", line 1, in ? > > AssertionError > > >>> assert "two" in myform.render(value=nestedvalues) > > Traceback (most recent call last): > > File "<console>", line 1, in ? > > AssertionError > > >>> assert "one" in myform.render(value=flatvalues) > > >>> assert "two" in myform.render(value=flatvalues) > > >>> > > > > Is there an easy way to fix this? > > > > Thanks > > > > Ed > > > > On 08/05/06, Michele Cella <[EMAIL PROTECTED]> wrote: > > > > > > Hi Ed, > > > > > > 1) change: > > > > > > params = ["fieldsets"] > > > > > > to: > > > > > > member_widgets = ["fieldsets"] > > > > > > I told you about this in your last thread but you probably missed it, > > > it's quite important since fieldsets are not simple params but member > > > widgets of your form, you need this for validating and passing values, > > > also member_widgets are not overridable at render/display time. > > > > > > 2) change: > > > > > > values=myformvalues > > > > > > to: > > > > > > value=myformvalues > > > > > > I also suggest to change: > > > > > > fieldsets=(MyForm()) > > > > > > into: > > > > > > fieldsets=MyForm() > > > > > > but that's not a big problem. > > > > > > Ciao > > > Michele > > > > > > Ed Singleton wrote: > > > > I can't seem to pass values into a nested forms. It's probably a > > > > simple error on my part but I can't work it out to save my life. > > > > > > > > from turbogears.widgets import * > > > > > > > > class MultiFieldSet(Form): > > > > template = """ > > > > <form xmlns:py="http://purl.org/kid/ns#" > > > > name="${name}" > > > > action="${action}" > > > > method="${method}" > > > > class="tableform" > > > > py:attrs="form_attrs" > > > > > > > > > <div py:for="fieldset in fieldsets" > > > > py:replace="fieldset.display(value_for(fieldset), > > > > **params_for(fieldset))" > > > > /> > > > > > > > > </form> > > > > """ > > > > params = ["fieldsets"] > > > > fieldsets = [] > > > > > > > > class FS1(WidgetsList): > > > > f1 = TextField() > > > > > > > > class FS2(WidgetsList): > > > > f2 = TextField() > > > > > > > > class MyForm(WidgetsList): > > > > fs1 = FieldSet(fields=FS1()) > > > > fs2 = FieldSet(fields=FS2()) > > > > > > > > myform = MultiFieldSet(fieldsets=(MyForm())) > > > > > > > > myformvalues = dict(fs1=dict(f1="one"),fs2=dict(f2="two")) > > > > > > > > assert "one" in myform.render(values=myformvalues) > > > > > > > > The assert fails for me. > > > > > > > > Any help would be greatly appreciated > > > > > > > > Thanks > > > > > > > > Ed > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

