@@ -2053,7 +2053,7 @@ def field(self, showid=0, size=None, **kwargs):
20532053 ** kwargs )
20542054
20552055 def menu (self , size = None , height = None , showid = 0 , additional = [], value = None ,
2056- sort_on = None , html_kwargs = {}, translate = True , ** conditions ):
2056+ sort_on = None , html_kwargs = {}, translate = True , showdef = None , ** conditions ):
20572057 """ Render a form select list for this property
20582058
20592059 "size" is used to limit the length of the list labels
@@ -2071,6 +2071,11 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
20712071 "translate" indicates if we should do translation of labels
20722072 using gettext -- this is often desired (e.g. for status
20732073 labels) but sometimes not.
2074+ "showdef" marks the default value with the string passed
2075+ as the showdef argument. It is appended to the selected
2076+ value so the user can reset the menu to the original value.
2077+ Note that the marker may be removed if the length of
2078+ the option label and the marker exceed the size.
20742079
20752080 The remaining keyword arguments are used as conditions for
20762081 filtering the items in the list - they're passed as the
@@ -2139,8 +2144,13 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
21392144
21402145 # figure if this option is selected
21412146 s = ''
2147+ # record the marker for the selected item if requested
2148+ selected_mark = ''
2149+
21422150 if value in [optionid , option ]:
21432151 s = 'selected="selected" '
2152+ if ( showdef ):
2153+ selected_mark = showdef
21442154
21452155 # figure the label
21462156 if showid :
@@ -2150,6 +2160,7 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
21502160 else :
21512161 lab = option
21522162
2163+ lab = lab + selected_mark
21532164 # truncate if it's too long
21542165 if size is not None and len (lab ) > size :
21552166 lab = lab [:size - 3 ] + '...'
0 commit comments