Thanks, This did not only clear up this particular problem for me but seeing the format in the IS_IN_DB constructor showed me why I was losing the default table represents when adding constraints elsewhere so that is now sorted too.
Thanks again. We expect to exceed ten thousand dockets. What will happen regarding the dropdown representation for columns referencing the dockets id as the number grows? Will I need to introduce a custom solution for this? On 19 February 2013 03:37, Massimo Di Pierro <massimo.dipie...@gmail.com>wrote: > The only problem is that for self referendes you do not get an automatic > represent and validator (because the field is created before the table > referenced is created): > > You can do it manually: > > db.define_table('Docket', > Field('Docket_No', 'integer', > required = True), > Field('Reference_Docket_ID', 'reference Docket', > required = False), > Field('Reference_Docket_No', 'integer', > required = False), > ... > > db.Docket.Reference_Docket_ID.requires=IS_IN_DB(db,'Docket. > Reference_Docket_ID','%(Docket_No)s')) > db.Docket.Reference_Docket_ID.represent=lambda value,row: value > > > On Monday, 18 February 2013 02:19:04 UTC-6, Paul Whipp wrote: >> >> Here is an example of what I need to do: >> >> db.define_table('Docket', >> Field('Docket_No', 'integer', >> required = True), >> Field('Reference_Docket_ID', 'reference Docket', >> required = False), >> Field('Reference_Docket_No', 'integer', >> required = False), >> ... >> >> The docket optionally refers to a preceding docket in the model. It >> appears that web2py's DAL ignores the required = False specification for >> this field because when I use the SQLFORM it tells me that 'Reference >> Docket_ID' is a required field so its impossible to enter any docket >> records. >> >> The client database is postgresSQL >> >> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = >> IS_NULL_OR(IS_IN_DB(...))) >> but then it fails to display the dropdown when the form is presented. >> >> With hundreds of tables, I don't want to have to craft the form by hand. >> >> I'm also wondering what happens when there are many thousands of dockets >> - will the dropdown for the Reference_Docket_ID on the form cope >> effectively? >> >> Cheers, >> Paul >> >> -- > > --- > 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/groups/opt_out. > > > -- --- 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/groups/opt_out.