On Tuesday, November 29, 2016 at 8:52:07 AM UTC-5, Sundar wrote: > > Yes- it looks very bad. I think the below method will work. (Let me know > if you need any elaboration) > > rofields = [db.<table>.field1, .....] > hidden = {} > for f in rofields: > fname = str(f).split('.')[1] > hidden[fname] = r[fname] > form1 = SQLFORM(db.<table>, record=<recid> , showid=True, hidden=hidden) >
Note, to get the name of a field, just do field.name. Also, not sure why the hidden fields (SQLFORM won't do anything with their contents), and I don't see "r" defined anywhere. Some simpler code to disable the form fields: [form1.element(_name=f.name).update(_disabled=True) for f in rofields] An alternative approach is to change the widgets associated with read-only fields: for field in db.mytable: if field.readable and not field.writable: field.widget = lambda f, v: SQLFORM.widgets[field.type].widget(f, v, _disabled=True) form = SQLFORM(db.mytable, record).process() Anthony -- 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/d/optout.