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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to