The seconde choice seems to be what I was search for... I was know about
.render(), but as you explain it is for rows only and don't apply when I
use this short cut : db.table(id_of_record).field

Thanks a lot.

Richard


On Fri, Nov 8, 2013 at 4:59 PM, Anthony <abasta...@gmail.com> wrote:

> Are you saying you want the "represent" function applied specifically to a
> reference field?
>
> Note, a Row object does not know with what DAL table it is associated, so
> it can't automatically apply the "represent" attributes of its fields.
> However, the Rows object has a new .render() method for this purpose -- see
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Rendering-rows-using-represent.
> In this case:
>
> {{=db(db.table.id == id).select().render(0).field}}
>
> Above, .render(0) extracts the first Row and applies the "represent"
> attributes to all fields.
>
> For reference fields, you can also simply do a recursive select as long as
> you know the name of the field to be used to "represent" the reference:
>
> {{=db.table(id).reference_field.field_in_referenced_table}}
>
> Anthony
>
>
>
> On Friday, November 8, 2013 4:06:40 PM UTC-5, Richard wrote:
>>
>> Hello,
>>
>> How can I do this :
>>
>> db.table(id).field.represent
>>
>> Could a short cut be created to handle this use case?
>>
>> {{=form.custom.begin}}
>> <table class="table table-condensed table-hover">
>>     <thead><tr><th>{{=T('Field label')}}</th></tr></thead>
>>     <tbody>
>>         {{for r in rows:}}
>>             <tr>
>>                 {{if record_id is not None and r.id == record_id:}}
>>                     <td>{{=form.custom.widget.referenced_field_id}}</td>
>>
>>                 {{else:}}
>>                     <td>{{=db.table(r.id).referenced_field_id.represent}
>> }</td>
>>                    * <!-- So I don't have to do -->*
>> *                    <!--
>> {{=db.referenced_table(r.referenced_field_id).field_representing_id_referenced}}
>> -->*
>>                 {{pass}}
>>             </tr>
>>         {{pass}}
>>
>>     </tbody>
>> </table>
>> {{=form.custom.end}}
>>
>>
>> Thanks
>>
>> Richard
>>
>  --
> 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.
>

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