Hi Hiphlod, You are right, I copied from my code a conditional button but without removing all unnecessary code.
links = [dict(header=A(XML(STRONG('Stato')), _class='button btn'), body=lambda row: (A(XML(' Pubblica ' ), _class='button btn btn-default', _href=URL('pubblica', args=[row.id, 'vision']) A('Pubblicata!', _class='button btn btn-success', _href=URL('pubblica', args=[row.id, 'vision'])), )[row.is_active], )] Now I understand my mistake but I looked like a bug because the button in the "links" worked in every record in the grid but not in "view" and "edit" views. Sorry for the noise! Fabrizio Il giorno lunedì 21 settembre 2015 22:42:55 UTC+2, Niphlod ha scritto: > > IMHO you copy/pasted one time too much. > > when you feel there's a bug, start with a smaller example and reiterate... > > the links argument accepts > > """ > a list of dict(header='name',body=lambda row: A(...)) > """ > > Your code holds a couple of parenthesis more than needed, so the argument > to the lambda is not a single element but a tuple > > i.e. instead of doing > dict(header='name',body=lambda row: A(...)) > you're doing > dict(header='name',body=lambda row: *(*A(...)*)*) > notice the *()* parenthesis > > That's why link['body'](record)[0] resolves the bug in your code. > > > -- 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.