Hi

I have a field in my schema like this:

fruit = Choice(title=u'Fruit',
               description=u'An example choice field',
               default=None,
               required=True,
               values=('Apple', 'Orange', 'Banana', 'Strawberry'))

I want to specify a default value for this field but I want it to be from the list of values.

Is there a preferred way to do it or just do something like this:

fruit_values = ('Apple', 'Orange', 'Banana', 'Strawberry')

fruit = Choice(title=u'Fruit',
               description=u'An example choice field',
               default=fruit_values[0],
               required=True,
               values=fruit_values)

In the implementation of my content type, do I have to write 'Apple' for the default value again or there is another way? I want to avoid duplicating hardwired names.

Sorry if this is a dumb question

Thanks in advance

Lorenzo
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to