from Products.Archetypes.Field import StringField
from Products.Archetypes.Widget import SelectionWidget
...
StringField(
name='myfield',
vocabulary='_get_selection_vocab',
widget=SelectionWidget(
label_msgid='label_myfield',
format='select',
),
),
...
def _get_selection_vocab(self):
"""sample selection voc
"""
return DisplayList((('item01','Item One'),('item02','Item Two'),))
對於「複選」的欄位,使用 MultiSelectionWidget 就可搞定,如果選項過多,就要考慮是否改用 InAndOutWidget。
更多細節,從 Archetypes Developer Manual 找得到說明。
No comments:
Post a Comment