Great!!

Thank you Anthony for clarification. That exactly what I was needing.

I should have read more carefully validators section I guess.

:)

Richard


On Tue, Aug 13, 2013 at 6:03 PM, Anthony <[email protected]> wrote:

>
> I have table a that is referenced by table b, so there is a_id FK field in
>> table b. But now I want table c to reference table b but to discriminate
>> record I need the representation of a id in the dropbox of c form because b
>> table are meaning less with a id represent.
>>
>> It occurs that IS_IN_DB does not let you access the value of the
>> referenced table, I mean I can't do something like this :
>>
>> IS_IN_DB(db, 'b.id', represent_dict[a_id] + b.other_field)
>>
>
> The third argument to IS_IN_DB can be a callable that takes the row object
> from the select, so it can generate whatever representation you want. I'm
> not sure what you mean by represent_dict[a_id], but perhaps something like:
>
> IS_IN_DB(db, 'b.id', lambda r: db.table_a(r.a_id).some_field + r.
> other_field)
>
> If the representation is more complex, you can define a separate function
> rather than using a lambda.
>
> Also, note that IS_IN_SET can take a dictionary or list of tuples -- see
> the book section on it.
>
> Anthony
>
>  --
>
> ---
> 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.
>
>
>

-- 

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