From 50fde09299062c2858912af11c0e4fb7189865fe Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Sat, 7 Apr 2012 19:55:10 -0500 Subject: [PATCH] col3 in grid, thanks Jonathan --- VERSION | 2 +- gluon/sqlhtml.py | 49 +++++++++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/VERSION b/VERSION index 2f25fa13..bee197e1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.7 (2012-04-07 18:44:26) dev +Version 1.99.7 (2012-04-07 19:55:06) dev diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 86a7f5b7..f9201896 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -16,7 +16,7 @@ Holds: from http import HTTP from html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG, SCRIPT -from html import FORM, INPUT, LABEL, OPTION, SELECT, MENU +from html import FORM, INPUT, LABEL, OPTION, SELECT from html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE from html import URL, truncate_string from dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query @@ -1477,6 +1477,10 @@ class SQLFORM(FORM): search_widget='default', ignore_rw = False, formstyle = 'table3cols', + formargs={}, + createargs={}, + editargs={}, + viewargs={}, ): # jQuery UI ThemeRoller classes (empty if ui is disabled) @@ -1611,18 +1615,21 @@ class SQLFORM(FORM): _class='form_footer row_buttons %(header)s %(cornerbottom)s' % ui) create_form = edit_form = None + sqlformargs = dict(formargs) - if create and len(request.args)>1 and request.args[-2]=='new': + if create and len(request.args)>1 and request.args[-2] == 'new': check_authorization() table = db[request.args[-1]] + sqlformargs.update(createargs) create_form = SQLFORM( - table, ignore_rw = ignore_rw, formstyle = formstyle, - _class='web2py_form').process( - next=referrer, - onvalidation=onvalidation, - onsuccess=oncreate, - formname=formname) - res = DIV(buttons(),create_form,formfooter,_class=_class) + table, ignore_rw=ignore_rw, formstyle=formstyle, + _class='web2py_form', + **sqlformargs) + create_form.process(formname=formname, + next=referrer, + onvalidation=onvalidation, + onsuccess=oncreate) + res = DIV(buttons(), create_form, formfooter, _class=_class) res.create_form = create_form res.edit_form = None res.update_form = None @@ -1631,10 +1638,12 @@ class SQLFORM(FORM): check_authorization() table = db[request.args[-2]] record = table(request.args[-1]) or redirect(URL('error')) - form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, - formstyle=formstyle, readonly=True,_class='web2py_form') - res = DIV(buttons(edit=editable,record=record),form, - formfooter,_class=_class) + sqlformargs.update(viewargs) + view_form = SQLFORM(table, record, upload=upload, ignore_rw=ignore_rw, + formstyle=formstyle, readonly=True, _class='web2py_form', + **sqlformargs) + res = DIV(buttons(edit=editable, record=record), view_form, + formfooter, _class=_class) res.create_form = None res.edit_form = None res.update_form = None @@ -1643,17 +1652,19 @@ class SQLFORM(FORM): check_authorization() table = db[request.args[-2]] record = table(request.args[-1]) or redirect(URL('error')) - edit_form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, - formstyle=formstyle,deletable=deletable, + sqlformargs.update(editargs) + edit_form = SQLFORM(table, record, upload=upload, ignore_rw=ignore_rw, + formstyle=formstyle, deletable=deletable, _class='web2py_form', - submit_button = T('Submit'), - delete_label = T('Check to delete')) + submit_button=T('Submit'), + delete_label=T('Check to delete'), + **sqlformargs) edit_form.process(formname=formname, onvalidation=onvalidation, onsuccess=onupdate, next=referrer) - res = DIV(buttons(view=details,record=record), - edit_form,formfooter,_class=_class) + res = DIV(buttons(view=details, record=record), + edit_form, formfooter, _class=_class) res.create_form = None res.edit_form = edit_form res.update_form = None