I think that it would be practical to have the option when calling
SQLTABLE to specify images in place of id links.
Here is how i would change it (seems to work with version 1.99.2)
diff -r 7dd85a51bb2a gluon/sqlhtml.py
--- a/gluon/sqlhtml.py Tue Nov 29 22:32:30 2011 -0600
+++ b/gluon/sqlhtml.py Wed Nov 30 21:50:01 2011 -0300
@@ -1972,6 +1972,7 @@
optional arguments:
:param linkto: URL (or lambda to generate a URL) to edit
individual records
+ :param imagelink: URL of an image to wrap the linkto field
:param upload: URL to download uploaded files
:param orderby: Add an orderby link to column headers.
:param headers: dictionary of headers to headers redefinions
@@ -2043,6 +2044,7 @@
self,
sqlrows,
linkto=None,
+ imagelink=None,
upload=None,
orderby=None,
headers={},
@@ -2146,7 +2148,7 @@
href = linkto(r, 'table', tablename)
except TypeError:
href = '%s/%s/%s' % (linkto, tablename,
r_old)
- r = A(r, _href=href)
+ r = self.image_link(r, href, imagelink)
elif field.type.startswith('reference'):
if linkto:
ref = field.type[10:]
@@ -2247,6 +2249,14 @@
return css
+
+ def image_link(self, r, href, imagelink):
+ if isinstance(imagelink, basestring):
+ return A(IMG(_src=imagelink, _alt=r), _href=href)
+ else:
+ return A(r, _href=href)
+
+
form_factory = SQLFORM.factory # for backward compatibility,
deprecated