I have a person table[1] with a parent field with a clickable
representation view of the record. If I put this on a grid and click on
the link, I get a "not authorized" error message. I thought I need to
pass the signature so I can make it viewable. (This works fine if
parameter user_signature=False)
Also, I have defined a default representation for the person table but
in my validation statement, note that I had to specify the same format
again. I'm wondering if there's a way to tell the validator to use the
default representation of the person (which I thought was web2py's
default behavior.)
In my grid, I specified a new button [2] in the links parameter, how do
I specificy an icon for this button? For example I want to use what's
already in base.css (book, heart, cross etc.)
/r
Nik
[1]
db.define_table('person'
,Field('birth_date', 'date', requires=IS_DATE())
,Field('last_name', notnull=True)
,Field('given_name', notnull=True)
,Field('parent', 'list:reference person'
,requires=IS_EMPTY_OR(IS_IN_DB(db, 'person.id'
,'%(last_name)s,
%(given_name)s [%(birth_date)s]'
,multiple=True
,zero=T('pick one')))
,represent = lambda value, row: [A(' ▸'+
db.person[v].given_name , _href = URL('index/view/person', args=[v]))
for v in value])
,auth.signature
,format='%(last_name)s, %(given_name)s [%(birth_date)s]'
)
[2]
form=SQLFORM.grid( db.person
,fields=[db.person.id, db.person.last_name,
db.person.given_name
,db.person.middle_name,
db.person.gender, db.person.birth_date, db.person.parent]
,showbuttontext=False
,sorter_icons=('[▴]','[▾]')
,onvalidation=person_processing
,links = [lambda row: A('X',
_href=URL(args=["view", db.person, row.id] ))]
)