Here is how I do it for tags
@auth.requires_membership('editor')
def edit():
d = db.sometable
t = db.tag # has fields name, record_id
record = d(request.args(0)) or redirect(URL('index'))
def update_tags(form):
db(t.record_id==record.id).delete()
for tag in request.vars.tags.split(','):
tag = tag.strip()
if tag:
t.insert(record_id=record.id,name=tag)
form = crud.update(d,record,
onaccept=update_tags,
next=URL('root',args=record.path))
tags = [tag.name for tag in db(t.record_id==record.id).select()]
form.element('table').insert(-2,TR(LABEL('Tags:'),INPUT(_name='tags',value=','.join(tags)),''))
return locals()
On May 22, 9:04 pm, blackthorne <[email protected]> wrote:
> I have two tables connected. One is owners, the other is dogs.
> Let's say I'm listing owners with a nice SQLTABLE(db.owners).
>
> Now I wanted to add a column in the generated table with the number of
> owned dogs db(db.dogs.owner == owner).count() so the end result would
> be SQLTABLE with an extra column. Is there an easy way to make this
> happen with SQLTABLE?
>
> Second, is there a way to change the displayed order of the SQLTABLE
> columns?
>
> Thank you,
> Best regards