see this example.

http://lucasmanual.com/mywiki/TurboGears#head-9735b22d17d95961a0218e66d8a20b188bd60551

class AddressBookFields(widgets.WidgetsList):
    firstname = widgets.TextField(validator=validators.NotEmpty)
    description = widgets.TextArea(validator=validators.NotEmpty)
    homepage = widgets.TextField(validator=validators.URL)
    yourcarvalue = widgets.TextField(label="Car Value",
validator=validators.Money(not_empty="True"))
    zipcode = widgets.TextField(label="ZipCode",validator=validators.PostalCode)
    age = widgets.TextField(label="Your Age",validator=validators.Int)
    sex = 
widgets.SingleSelectField(label="Gender",validator=validators.NotEmpty,
options=['Female','Male'])
    maritalstatus = widgets.SingleSelectField(label="Marital Status",
validator=validators.NotEmpty, options=['Single','Married'])

On 9/8/07, badfrog <[EMAIL PROTECTED]> wrote:
>
> I've defined and imported these classes into a tg-admin shell session:
>
> class CustomerFormFields(widgets.WidgetsList):
>
>     name = widgets.TextField(
>
>         validator=validators.NotEmpty(),
>
>         label="Name (First Last)"
>
>     )
>
>     nickName = widgets.TextField(
>
>         validator=validators.NotEmpty(),
>
>         label="Tag/Nickname"
>
>     )
>
>     dateOfBirth = widgets.CalendarDatePicker(
>
>         validator=validators.DateTimeConverter(),
>
>         label="Date of Birth"
>
>     )
>
>
> class PhoneFormFields(widgets.WidgetsList):
>
>     name = widgets.TextField(
>
>         label = "Label",
>
>         attrs = dict(size = 50)
>
>     )
>
>
>
>     number = widgets.TextField(
>
>         label = "Number",
>
>         attrs = dict(size = 12)
>
>     )
>
> here's the session text:
>
> >>> from forms import *
> >>> from turbogears import widgets
> >>> l = []
> >>> l.append(CustomerFormFields())
> >>> l.append(PhoneFormFields())
> >>> f = widgets.TableForm(fields=l)
> Traceback (most recent call last):
> [...]
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 169, in widget_init
>     validator = generate_schema(self.validator, widgets)
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 277, in generate_schema
>     if widget.is_named:
> AttributeError: 'CustomerFormFields' object has no attribute
> 'is_named'
> >>> f2 = widgets.TableForm()
> >>> f2.fields.append(CustomerFormFields())
> >>> f2.fields.append(PhoneFormFields())
> >>> f2.display()
> Traceback (most recent call last):
>  [...]
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/forms.py", line 554, in update_params
>     if field.name not in d["disabled_fields"]:
> AttributeError: 'CustomerFormFields' object has no attribute 'name'
> >>> f3 = widgets.TableForm()
> Traceback (most recent call last):
>   [...]
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 169, in widget_init
>     validator = generate_schema(self.validator, widgets)
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 277, in generate_schema
>     if widget.is_named:
> AttributeError: 'CustomerFormFields' object has no attribute
> 'is_named'
>
> Questions:
> Am I missing something from my WidgetsList classes that's causing
> these AttributeErrors?
> Can I not append to the form's fields collection, or use a list to put
> together a bunch of WidgetLists?
> Why does an error on one TableForm cause errors on another unrelated
> instance that doesn't even have any widgets in it?
> I've noticed similar behavior if I call TableForm.display() more than
> once on the same form instance. Is this a no-no?
> I've looked at the Widget Toolbox, and the tutorials, and they are all
> really helpful, but what seems to be really missing is API
> documentation. Some of the __doc__ strings are helpful, but others
> aren't set or don't really illuminate anything. Is there any existing
> documentation?
>
> TIA!
>
>
> >
>


-- 
-- 
Linux is not magic. It just works.
http://www.lucasmanual.com
Fax Server from start to finish:
http://www.lucasmanual.com/pdf/FaxServer.pdf

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