My suggestion is do not use crud.select(). Do something like
Controller:
def kit():
table=db.kit
items=db().select(table.ALL) ### list is a keyword in python
return dict(items=items,table=table)
and in view
{{for item in items:}}
<button onclick="$('#h{{=item.id}}').slideToggle()">{{=item.id}}</
button>
<div id="h{{=item.id}}" class="h">
{{form=SQLFORM(table,item.id,formname=item.id)}}{{=form}}
{{if form.accepts(request.vars,session): redirect(URL(r=request))}}
</div>
{{pass}}
<script>$(document).ready(function(){$('.h').hide()});</script>
Massimo
On Apr 17, 3:23 pm, Fran <[email protected]> wrote:
> I am using crud.select() to show a nice SQLTABLE list of the items in
> a kit.
> What I'd like to be able to do is to amend the quantity of items
> directly within this table, but my attempts so far are failing because
> I can't pass the row into the .represent.
>
> Simplified model:
> db.define_table('kit',db.Field('item_id'),db.Field('quantity'))
>
> Controller:
> def kit():
> table=db.kit
> table.quantity.represent=lambda qty: INPUT
> (value=qty,requires=IS_NOT_EMPTY())
> list=crud.select(table)
> return dict(list=list)
>
> I want to be able to do something like:
> table.quantity.represent=lambda qty,record: INPUT
> (value=qty,_name=record,requires=IS_NOT_EMPTY())
>
> table.quantity.represent=lambda qty: SQLFORM(table,record,fields=
> ['quantity'],showid=False)
> table.quantity.represent=lambda qty: FORM(INPUT
> (value=qty,_name=record,requires=IS_NOT_EMPTY()))
>
> If I can't do form-fields directly inside the table then at least
> links would be good, but this has the same problem:
> table.quantity.represent=lambda qty: A(qty,_href=URL
> (r=request,f='kit_quantity',args=[record,qty]))
>
> How can I pass the record into the lambda?
> - or do something which achieves the same thing...
>
> Many thanks,
> Fran.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---