I read what you're saying however if I make *one simple change*:
formcontrol.category.writable = False
Then it shows the category name, but not in a dropdown list.
This form is being generated with:
form=crud.update(db.animals,animals,next=url('currentanimals'),onvalidation=
my_form_processing)
Which obviously is not SQLFORM, it is CRUD. So according to what you said
I should not be able to use represent, yet there it is working.
*Why does commenting this out cause it to not work?*
formcontrol.category.writable = False
The *dropdown box returns* but, *without the names* and *shows the IDs*
again. This does not correlate with anything in the book, nor with your
statement above.
*Is this a bug?*
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 [email protected].
For more options, visit https://groups.google.com/d/optout.