The problem is that while you get the same fields in the same order this may have the effect of overriding the field.readable and field.writable attributes. The fields argument of the grid can be a subset of the list of writable fields in forms and it is intended to select a subset. Now you are limiting forms too to that subset.
Massimo On Thursday, 12 December 2013 08:04:21 UTC-6, P T wrote: > > I rigged the sqlhtml.py, so that I can rearrange the fields in the form as > well. The following worked for me, but not sure if it has any side effects: > > In sqlhtml.py, after the line > create_form = update_form = view_form = search_form = None > > insert > > fieldnames = [f.name for f in fields] > > and include fieldnames in the following calls: > > create_form = SQLFORM(table, fields=fieldnames, **sqlformargs) > > view_form = SQLFORM(table, record, fields=fieldnames,**sqlformargs) > > update_form = SQLFORM(table, record, fields=fieldnames, **sqlformargs) > > > I think, it would be nice to see the fields in the same arrangement both > in grid and forms. This will also filter fields in the form. Currently, > forms show all fields from the table. > > Thanks, > PT > > On Wednesday, December 11, 2013 8:34:36 PM UTC-6, Massimo Di Pierro wrote: >> >> Now I understand better. The order of the parameters in forms is >> specified in the table definition. You can rearrange in the grid view but >> not in form. >> I assume the order is fixed. You should change it in the >> define_table(..., *fields) >> >> >> On Tuesday, 10 December 2013 00:09:49 UTC-6, P T wrote: >>> >>> I think, the problem is due to the following calls in gluon.sqlhtml.py >>> (lines 2050, 2072, and 2093), which does not include the optional parameter >>> "fields" >>> >>> create_form = SQLFORM(table, **sqlformargs) >>> view_form = SQLFORM(table, record, **sqlformargs) >>> update_form = SQLFORM(table, record, **sqlformargs) >>> >>> So, I tried something like >>> >>> update_form = SQLFORM(table, record, fields=fields, >>> **sqlformargs) >>> >>> and this generates the ticket >>> >>> <type 'exceptions.AttributeError'> 'Field' object has no attribute >>> 'find' >>> >>> Version >>> web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 >>> Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) >>> Traceback (most recent call last): >>> File "C:\web2py-src\gluon\restricted.py", line 217, in restricted >>> exec ccode in environment >>> File "C:/web2py-src/applications/Test/controllers/default.py", line >>> 77, in <module> >>> File "C:\web2py-src\gluon\globals.py", line 372, in <lambda> >>> self._caller = lambda f: f() >>> File "C:\web2py-src\gluon\tools.py", line 3239, in f >>> return action(*a, **b) >>> File "C:/web2py-src/applications/Test/controllers/default.py", line >>> 20, in index >>> grid = SQLFORM.grid(query, fields=fields) >>> File "C:\web2py-src\gluon\sqlhtml.py", line 2093, in grid >>> update_form = SQLFORM(table, record, fields=fields, >>> **sqlformargs) >>> File "C:\web2py-src\gluon\sqlhtml.py", line 1053, in __init__ >>> if fieldname.find('.') >= 0: >>> AttributeError: 'Field' object has no attribute 'find' >>> >>> There must be something wrong in how I included the fields param here. >>> >>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.