我希望我的自定义类型显示存储的词汇的标题。字段定义如下所示:
atapi.LinesField(
'member_field',
searchable=1,
index='KeywordIndex',
multiValued=1,
storage=atapi.AnnotationStorage(),
vocabulary_factory='member_name',
widget=AutocompleteWidget(
label=_(u"Member Name"),
description=_(u"Multiple Lines, One Per Line."),
actb_timeout=-1,
actb_expand_onfocus=0,
actb_filter_bogus=0,
),
enforceVocabulary=0,
),
词汇定义如下所示:
class member_name(object):
implements(IVocabularyFactory)
def __call__(self, context=None):
items = (
SimpleTerm(value='john', title=u'John Doe'),
SimpleTerm(value='paul', title=u'Paul Smith'),
... ...
)
return SimpleVocabulary(items)
member_nameFactory = member_name()
相应的页面模板如下所示:
<div tal:define="mbrs context/member_field|nothing"
tal:condition="mbrs">
Member List:
<span tal:repeat="mbr mbrs">
<span tal:replace="mbr">Member Name</span>
<span class="separator"
tal:condition="not: repeat/mbr/end" tal:replace="string:, " />
</span>
</div>
仅显示值的示例结果如下所示Member List: paul , john
:我怎样才能显示他们的标题,例如:Member List: Paul Smith , John Doe
?