Reputation: 344
I would like to know if its possible to create a form using:
record = request.args(0)
form = SQLFORM.factory(db.tbl1, db.tbl2, db.tbl3, db.tbl4, record)
Is this possible, as I keep getting an error when I try it.
define_table argument is not a Field or Table: 1
Upvotes: 0
Views: 1025
Reputation: 25536
Positional arguments to SQLFORM.factory
can only be fields or tables (from which the fields will be extracted). Other arguments must be passed as keyword arguments:
form = SQLFORM.factory(..., record=record)
However, passing a record ID as the record
argument to SQLFORM.factory
won't work because SQLFORM.factory
generates a dummy DAL
instance with a dummy table, so it won't be able to query the dummy table using the record ID in order to retrieve a record. In any case, it is not clear to which record your record ID would refer (you're form comprises four separate db tables).
If your goal is to use the record to pre-populate the form values, an alternative is to set the field defaults to those values.
Upvotes: 1