Hello List,
form['shipBill'] = ShipBillForm(
name='shipBillForm',
action='/shop/checkoutSummaryPay',
form_attrs=dict(id='shipBillForm'),
shippingAddress=CompoundFormField(name='shippingAddress',
fields=[
TextField(name='shippingFirstName', label='First
Name:', validator=vs.String()),
TextField(name='shippingLastName', label='Last Name:',
validator=vs.String()),
TextField(name='shippingAddressOne', label='Address:',
validator=vs.String()),
TextField(name='shippingAddressTwo', label=' ',
validator=vs.String()),
TextField(name='shippingCity', label='City:',
validator=vs.String()),
SingleSelectField(name='shippingState',
label='State:', validator=vs.String(), options=getStates),
TextField(name='shippingZipcode', label='Zipcode:',
validator=vs.String()),
SingleSelectField(name='shippingCountry',
label='Country:', validator=vs.String(), options=getCountries,
attrs=dict(onchange='updateShippingState();'))],
hidden_fields=[]),
billingAddress=CompoundFormField(name='billingAddress',
fields=[
TextField(name='billingFirstName', label='First
Name:', validator=vs.String()),
TextField(name='billingLastName', label='Last Name:',
validator=vs.String()),
TextField(name='billingAddressOne', label='Address:',
validator=vs.String()),
TextField(name='billingAddressTwo', label=' ',
validator=vs.String()),
TextField(name='billingCity', label='City:',
validator=vs.String()),
SingleSelectField(name='billingState', label='State:',
validator=vs.String(), options=getStates),
TextField(name='billingZipcode', label='Zipcode:',
validator=vs.String()),
SingleSelectField(name='billingCountry',
label='Country:', validator=vs.String(), options=getCountries,
attrs=dict(onchange='updateBillingState();'))],
hidden_fields=[]),
shippingType=CompoundFormField(name='shippingType',
fields=[
SingleSelectField(name='shippingTypeId',
label='Type:', options=getShippingTypeOptions, validator=vs.Int())],
hidden_fields=[]),
fields=[],
hidden_fields=[
HiddenField(name='shippingAddressId', validator=vs.Int()),
HiddenField(name='billingAddressId', validator=vs.Int())])
What you just saw was a disgustingly large widget form. I use
compound form fields so that I can access the fields in groups from
within the template. Like so:
<tr py:for="i, field in enumerate(shippingAddress.fields)"
class="${i%2 and 'odd' or 'even'}">
FIrst off is there a better way to access groups of fields within a
template than to do that ? And secondly how can I disable all the
billingAddress fields at display time(make them dissappear)? For
example disabled_fields = ['billingFirstName',...] is not working
either in the main form or if I try to pass it by path to the
CompoundFormField with name billingAddress like so:
shipBillForm(disabled_fields=dict(billingAddress=['billingFirstName',...]))
Any suggestions would be greatly appreciated.
Thanks.
-Ian
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---