Hi all, I'm wondering if anyone knows what the best way is to change validators on a table's input form. In my program, if the record is initially added, I only need the validators to check a subset of fields (IS_NOT_EMPTY, etc.), but in another state I need to check them all.
My first attempt involved dynamically recreating the form initially with SQLFORM.factory and later using normal SQLFORM, using different validators in the 'requires' parameter of each Field. This was causing problems with the workflow because in the later state there was no way to edit the record and come back to it later because every field had to be filled in, which is not practical. So I changed it to specify the 'requires' validators on the DAL object (db) like this: db.table_name.field_name.requires = [ IS_NOT_EMPTY(), ... ] form = SQLFORM(...) form.process() This works great, but it feels like the wrong thing to do, since it is changing the validators for the table, not the form. It works fine across sessions, but the validators do persist to the next form for that table in the same session, which is fine as long as I remember to set them properly before every SQLFORM. Is there a better way to do this? Is there perhaps some way to reach into the SQLFORM and pull out the fields and their validators? I went spelunking in that code but came up empty-handed. It's pretty dense stuff. Thanks, -Mike --