support for 'dropdown' field
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2023 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
6960f85b8f
commit
feeb21e1e3
2 changed files with 13 additions and 0 deletions
|
@ -39,6 +39,7 @@ class Field(Component):
|
||||||
|
|
||||||
required = False
|
required = False
|
||||||
standardFieldName = None
|
standardFieldName = None
|
||||||
|
vocabulary = None
|
||||||
renderFactory = None
|
renderFactory = None
|
||||||
|
|
||||||
def __init__(self, name, title=None, fieldType='textline', **kw):
|
def __init__(self, name, title=None, fieldType='textline', **kw):
|
||||||
|
@ -58,6 +59,12 @@ class Field(Component):
|
||||||
def getTitleValue(self):
|
def getTitleValue(self):
|
||||||
return self.title or self.name
|
return self.title or self.name
|
||||||
|
|
||||||
|
def getVocabularyItems(self):
|
||||||
|
voc = (self.vocabulary or '')
|
||||||
|
if isinstance(voc, basestring):
|
||||||
|
voc = voc.splitlines()
|
||||||
|
return [dict(token=v, title=v) for v in voc if v.strip()]
|
||||||
|
|
||||||
def getFieldTypeInfo(self):
|
def getFieldTypeInfo(self):
|
||||||
return fieldTypes.getTerm(self.fieldType)
|
return fieldTypes.getTerm(self.fieldType)
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,12 @@ class IField(IComponent):
|
||||||
'(only for type textarea)'),
|
'(only for type textarea)'),
|
||||||
default=3,
|
default=3,
|
||||||
required=False,)
|
required=False,)
|
||||||
|
vocabulary = schema.Text(
|
||||||
|
title=_(u'Vocabulary'),
|
||||||
|
description=_(u'Values that may be selected as values for '
|
||||||
|
'this field; enter one value per line '
|
||||||
|
'(only for dropdown and other selection fields)'),
|
||||||
|
required=False,)
|
||||||
|
|
||||||
renderFactory = Attribute('A class or another factory providing an '
|
renderFactory = Attribute('A class or another factory providing an '
|
||||||
'object used for rendering the data e.g. as a '
|
'object used for rendering the data e.g. as a '
|
||||||
|
|
Loading…
Add table
Reference in a new issue