If you don't explicitly specify a validator for a reference field and the 
referenced table has a "format" attribute, then you get a default validator 
*and* a default "represent" attribute (the "represent" attribute is what is 
used for read-only displays). However, if you explicitly specify your own 
validator, then you no longer get the default "represent" attribute either, 
and so you must explicitly provider your own. You could do something like:

Field('myfield', 'represent othertable', requires=...,
      represent=lambda id, r: db.othertable._format % db.othertable(id) ifid 
else '')

Anthony

On Thursday, February 13, 2014 6:08:55 PM UTC-5, Mirek Zvolský wrote:
>
> As user of my application I don't want see any ID's at all - instead I 
> want always see record content formatted from format=..
>
> In smartgrid I am able to receive records instead of ID's only, if I run 
> with default validator for foreign key (i.e. without requires=..)
> In such case (without requires=..) I see related records for readonly 
> foreign keys (View) and for readwrite foreign keys (Edit).
> If I use requires=.. then for readonly foreign keys I see ID's and I have 
> no idea, how to prevent it.
>
> If I need a foreign key, which should be None for some records, then I 
> think it is necessary to use requires=IS_EMPTY_OR(IS_IN_DB(db, 
> db.parent.id))
> However this will display ID's instead of formatted records for readonly 
> foreign keys. :(((
>
> How to do it proper? Can represent=.. help? Or....?
>
> I try it with 2.8.2 version. Thanks for help !
> (Note: I don't know, if answer to my question was same in older versions, 
> or if it has changed in 2,8.2 with new constraint handling for SQLite.)
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.

Reply via email to