I have some functionality which generates a custom SQLFORM.factory form (reads/writes to different tables, handles uploads, etc.). All works fine but somewhere down the flow I just wanted to display that same form prefilled and readonly. For whatever reason I can't prefill it and make it readonly at the same time.
Let me illustrate with some code (not my exact code, just generic web2py code which does the same): I though to display a generic, readonly, prefilled form I should do this: def frm(): form = SQLFORM.factory( Field('test'), Field('best'), readonly=True ) form.vars = dict( test='abc', best='123' ) return dict(form=form) the form shows but instead of the default values it shows None. To show the default values I had to do this (remove readonly and add form.accepts (which for a readony form seems strange, I would never read from this form here)): def frm(): form = SQLFORM.factory( Field('test'), Field('best') ) form.vars = dict( test='abc', best='123' ) form.accepts(request.vars, session) return dict(form=form) so far so good by form ain't readonly. When I try to add the readonly back I get a readonly form but again with all values set to None: def frm(): form = SQLFORM.factory( Field('test'), Field('best'), readonly=True ) form.vars = dict( test='abc', best='123' ) form.accepts(request.vars, session) return dict(form=form) I must be missing something fundamental here. I could display that same information other ways I guess but I already have the code which builds it in a form I thought I could reuse. Thanks for looking into this...