Hi,
This is no longer the case. Thanks to some help in the chat channel it
now works.
There were several problems, like sending the string '1' instead of
the integer 1 to drop down lists strange nesting, and perhaps most
surprising to me using Caps.
I do not know if the last one is vital or not. Perhaps POST-data is
hard to map if caps is used.

With regards,
Zafer (runge in chat)



On 2 Apr, 21:55, runge <[email protected]> wrote:
> Hi,
> I use ToscaWidgets for my form handling and it have worked well for a
> while.
> Now that my widgets are more advanced, using both growing, hiding, and
> other compound widgets from dynforms and form I can not for the life
> of me figure out how to populate them. I have read in the mailing list
> that they need to be handled differently using some kind of child_arg
> parameter or some such. I have failed in that. I have also tried to
> just send in the post to the form hoping that TW would just handle it.
> I have tried to un-flattern the post data using
> formencode.variabledecode.variable_decode(form_fields)
>
> I am pretty new to Pyhton and turbogears in general so it is probably
> bad coding and not understanding it very well.
>
> I would be great to get some kind of example on how to do it. I will
> post some code in the hope that it will help you find out where I went
> wrong.
>
> My Controller:
> def sales(self, **form_fields):
>         tmpl_context.form2 = create_sales_form
>
> form_fields_dict=formencode.variabledecode.variable_decode(form_fields)
> ....
>         return dict(user=identity['repoze.who.userid'],
> child_args=dict(child_args=form_fields_dict), page='sales')
> having also tried:
>         return dict(user=identity['repoze.who.userid'],
> child_args=form_fields_dict, page='sales')
>         return dict(user=identity['repoze.who.userid'],
> child_args=form_fields, page='sales')
> also sending the form etcetc..
>
> My template:
> ${tmpl_context.form2(child_args)|n}
> having tried child_args=child_args, fields=child_args etc
>
> parts of my forms:
>
> class P1(twf.TableFieldSet):
>     class children(WidgetsList):
>         SiteSelect  =
> twf.SingleSelectField('SiteSelect',options=DBSession.query(Site.ID,
> Site.Name).order_by(Site.ID))
>         TradeSelect =
> twf.SingleSelectField(options=DBSession.query(Trade.ID,
> Trade.Name).filter(Trade.Active=='True').order_by(Trade.ID))
>         Phone       = TextField(label_text="Phone number ", size='15')
>
> class HidingSingleSelectField(twd.HidingTableFieldSet):
>     children = [
>                 twd.HidingRadioButtonList('Product',
> label_text='Product',default='Gratis Medverkan', options=('Gratis
> Medverkan','Medverkan','Medverkan Plus','Utokad Medverkan'),
>                                   mapping={
>                 'Gratis Medverkan': ['Gratis_Medverkan'],
>                 'Medverkan'       : ['Medverkan'],
>                 'Utokad Medverkan': ['Utokad_Medverkan'],
>                 'Medverkan Plus'  : ['Medverkan_Plus'],
>                                            }),
>         P1('Gratis_Medverkan',label_text=''),
>         P2('Medverkan',label_text=''),
>         P3('Medverkan_Plus',label_text=''),
>         P4('Utokad_Medverkan',label_text=''),
>
>     ]
>
> class Sales(TableForm):
>     submit_text = None
>     class children(WidgetsList):
>           my_hiding        =  HidingSingleSelectField(label_text='')
>         Update           =
> SubmitButton(attrs={'name':'submit','value':l_('Recalculate
> Information')})
>
> class SalesView(twf.TableFieldSet):
>     class children(WidgetsList):
>         Sales= Sales(label_text='')
>
> create_prospect_form = ProspectView("create_prospect_form" ,
> strip_name='True')
>
> create_sales_form = SalesView("create_sales_form",lable_text='' )
>
> The POST-information I get is:
> {'create_sales_form.Sales.my_hiding.Medverkan_Plus.Phone1': u'',
> 'create_sales_form.Sales.my_hiding.Medverkan.Homepage': u'',
> 'create_sales_form.Sales.my_hiding.Medverkan_Plus.my_addons.Banner.BannerType':
> u'0', 'create_sales_form.Sales.ID': u'',
> 'create_sales_form.Sales.my_hiding.Medverkan_Plus.my_addons.Banner.BLengthSelect':
> u'1',
> 'create_sales_form.Sales.my_hiding.Medverkan_Plus.SiteSelect.spare.Site':
> u'0', 'create_sales_form.Sales.BCity': u'',
> 'create_sales_form.Sales.my_hiding.Utokad_Medverkan.PicInfo': u'',
> 'create_sales_form.Sales.my_hiding.Medverkan.SiteSelect.gr........
>
> If needed I can post things to pastebin or some site like it. This
> thing have been driving me nuts for the past week.
>
> With regards,
> Zafer (runge in chat)

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