There isn't really an easy way to do what you want with SQLFORM.factory
. You can change "no_table" to something else via the table_name
argument, but that will affect all the form input fields. If you want to use SQLFORM.factory
(as opposed to generating a custom form), then you'll have to use the server-side DOM to manipulate the form object after it has been created. Something like:
form = SQLFORM.factory(db.table1, db.table2)
for f in [f for f in db.table1] + [f for f in db.table2]:
if f.type != 'id' and f.readable and f.writable:
form.element('tr[id=no_table_%s__row]' % f.name).add_class(
'%s_%s' % (f.tablename, f.name))
The above iterates through all the Field
objects in the two tables, and for each one, it finds the associated TR
element in the form based on the id
and then adds a class to the TR
.