Not sure if this is the problem, but your virtual field function should 
refer to row.translator.custom_name rather than row.custom_name.

Anthony

On Friday, February 14, 2014 8:00:17 AM UTC-5, Horst Horst wrote:
>
> Given this table...
>
> translator_format = lambda row: row.custom_name if (row.custom_name and 
> row.custom_name.strip()) else "%s -> %s" %(
>             db.notation(row.source_notation_id).notation_name,
>             db.notation(row.target_notation_id).notation_name)
>
> db.define_table("translator",
>     # A name for the translator is not required. If the custom name is 
> empty, the name will be computed 
>     # from the notation names
>     Field("custom_name", "string", length=512,
>           ),
>
>     Field.Virtual("translator_name",
>                   translator_format),
>     # ...
>     format = translator_format,
> )
>
> ... I'm trying to define this form:
>
> form = SQLFORM.factory(
>     Field("translator_id", "reference translator",
>           label=T("Translator"),
>           requires = IS_IN_DB(
>               db(translator_query), db.translator.id,
>               translator_chooser_representation,
>               zero=None, sort=False),
>     ),
>     # ...
>     )
>
> Now, within the format function, i cannot access the virtual field of the 
> row:
>
> def translator_chooser_representation(r):
>     return "%s" %(r.translator_name)   ## This I'd like to use but it 
> doesn't work
>
>     return db.translator._format(r)  ## This works, but I'd like the 
> actual result to be different from the format
>
> Am I doing something wrong?
>
>

-- 
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