@@ -2050,7 +2050,7 @@ def field(self, showid=0, size=None, **kwargs):
20502050 ** kwargs )
20512051
20522052 def menu (self , size = None , height = None , showid = 0 , additional = [], value = None ,
2053- sort_on = None , html_kwargs = {}, translate = True , ** conditions ):
2053+ sort_on = None , html_kwargs = {}, translate = True , showdef = None , ** conditions ):
20542054 """ Render a form select list for this property
20552055
20562056 "size" is used to limit the length of the list labels
@@ -2068,6 +2068,11 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
20682068 "translate" indicates if we should do translation of labels
20692069 using gettext -- this is often desired (e.g. for status
20702070 labels) but sometimes not.
2071+ "showdef" marks the default value with the string passed
2072+ as the showdef argument. It is appended to the selected
2073+ value so the user can reset the menu to the original value.
2074+ Note that the marker may be removed if the length of
2075+ the option label and the marker exceed the size.
20712076
20722077 The remaining keyword arguments are used as conditions for
20732078 filtering the items in the list - they're passed as the
@@ -2136,8 +2141,13 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
21362141
21372142 # figure if this option is selected
21382143 s = ''
2144+ # record the marker for the selected item if requested
2145+ selected_mark = ''
2146+
21392147 if value in [optionid , option ]:
21402148 s = 'selected="selected" '
2149+ if ( showdef ):
2150+ selected_mark = showdef
21412151
21422152 # figure the label
21432153 if showid :
@@ -2147,6 +2157,7 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
21472157 else :
21482158 lab = option
21492159
2160+ lab = lab + selected_mark
21502161 # truncate if it's too long
21512162 if size is not None and len (lab ) > size :
21522163 lab = lab [:size - 3 ] + '...'
0 commit comments