Skip to content

Commit 5b1813e

Browse files
author
Richard Jones
committed
allow preselection of values in templating menu()s (patch [SF#1396085])
1 parent 15588fd commit 5b1813e

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Feature:
1414
- Roundup installation document includes configuration example
1515
for Exim Internet Mailer (sf bug 1393860)
1616
- enable registration confirmation by web only (sf bug 1381675)
17+
- allow preselection of values in templating menu()s (sf patch 1396085)
1718

1819
Fixed:
1920
- MySQL now creates String columns using the TEXT column type

doc/customizing.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.187 $
5+
:Version: $Revision: 1.188 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -2035,6 +2035,8 @@ menu only on Link and Multilink properties - render a form select
20352035
(direction, property) where direction is '+' or '-'. A
20362036
single string with the direction prepended may be used.
20372037
For example: ('-', 'order'), '+name'.
2038+
value
2039+
gives a default value to preselect in the menu
20382040

20392041
The remaining keyword arguments are used as conditions for
20402042
filtering the items in the list - they're passed as the

roundup/cgi/templating.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,13 +1669,14 @@ def field(self, showid=0, size=None):
16691669
return '<input name="%s" value="%s" size="%s">'%(self._formname,
16701670
value, size)
16711671

1672-
def menu(self, size=None, height=None, showid=0, additional=[],
1672+
def menu(self, size=None, height=None, showid=0, additional=[], value=None,
16731673
sort_on=None, **conditions):
16741674
''' Render a form select list for this property
16751675
16761676
"size" is used to limit the length of the list labels
16771677
"height" is used to set the <select> tag's "size" attribute
16781678
"showid" includes the item ids in the list labels
1679+
"value" specifies which item is pre-selected
16791680
"additional" lists properties which should be included in the
16801681
label
16811682
"sort_on" indicates the property to sort the list on as
@@ -1692,7 +1693,8 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16921693
if not self.is_edit_ok():
16931694
return self.plain()
16941695

1695-
value = self._value
1696+
if value is None:
1697+
value = self._value
16961698

16971699
linkcl = self._db.getclass(self._prop.classname)
16981700
l = ['<select name="%s">'%self._formname]
@@ -1857,14 +1859,15 @@ def field(self, size=30, showid=0):
18571859
return self.input(name=self._formname,size=size,value=value)
18581860

18591861
def menu(self, size=None, height=None, showid=0, additional=[],
1860-
sort_on=None, **conditions):
1862+
value=None, sort_on=None, **conditions):
18611863
''' Render a form <select> list for this property.
18621864
18631865
"size" is used to limit the length of the list labels
18641866
"height" is used to set the <select> tag's "size" attribute
18651867
"showid" includes the item ids in the list labels
18661868
"additional" lists properties which should be included in the
18671869
label
1870+
"value" specifies which item is pre-selected
18681871
"sort_on" indicates the property to sort the list on as
18691872
(direction, property) where direction is '+' or '-'. A
18701873
single string with the direction prepended may be used.
@@ -1879,7 +1882,8 @@ def menu(self, size=None, height=None, showid=0, additional=[],
18791882
if not self.is_edit_ok():
18801883
return self.plain()
18811884

1882-
value = self._value
1885+
if value is None:
1886+
value = self._value
18831887

18841888
linkcl = self._db.getclass(self._prop.classname)
18851889

0 commit comments

Comments
 (0)