I tried this:
Field('category', 'reference category', requires=IS_IN_SET(catwanted,zero=
None),represent=lambda catwanted, r: db.category[catwanted].title if 
catwanted else "")

from what I saw in one of your posts, however it only still shows me the id 
and not the name being held in the field for that id.

will keep trying and if I succeed I will post here.  Again thanks for any 
and all help, this problem has been buggin me for a while.

On Monday, January 19, 2015 at 9:37:29 PM UTC-6, Anthony wrote:
>
> The "represent" attribute is used for read-only forms, SQLTABLE, 
> SQLFORM.grid, and when calling rows.render() -- it does not apply to update 
> forms (in that case, the field's widget controls what is displayed).
>
> Anthony
>
> On Monday, January 19, 2015 at 10:26:26 PM UTC-5, americandewd wrote:
>>
>> How would one go about troubleshooting "represent"?
>>
>> I am at the point where the ID matches the data I am looking for however 
>> it is not showing the title for the matching ID.
>>
>> Specifically I have categories held in this table:
>> db.define_table('category', 
>>     Field('title'),
>>     Field('slug',requires=IS_SLUG(),compute=lambda row: IS_SLUG.urlify(
>> row.title)),
>>     Field('parent_id','reference category', default=None))
>>
>> I have a table where these categories will be used:
>> db.define_table('animals',
>>     Field('name'),
>>     Field('breed'),
>>     Field('category', db.category),
>> )
>>
>>
>> I then exclude certain categories I don't want them to be able to post in:
>> catwanted = []
>> notwanted = ['Dogs','Cats','MiscPets']
>> for row in db(db.category).select():
>> if row.title in notwanted:
>>     pass
>> else:
>>     catwanted.append(row.title)
>> catwanted.sort()
>>
>>
>>
>> Then I have a form where I want to represent the title of the category.id 
>> it references so I use represent:
>> db.animals.category.represent = lambda f: db.category[f].title
>>
>> Instead of showing me the title it shows me the id of that category when 
>> I go to edit the record using crud.update.
>>
>> I had this issue before however the only difference is that I did not 
>> exclude anything, and it was not a dropdown; specifically I used this same 
>> exact thing to show me the name of the Animal when updating the status of 
>> the pet.
>>
>> No matter what or where I do with represent it doesn't change the list 
>> from the the ID to the title.
>>
>> I even tried creating this all from scratch and it does exactly the same 
>> thing, shows the ID but, not the title of the category.
>>
>

-- 
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/d/optout.

Reply via email to