Also, note that depending on how many tags there are, this method could be 
inefficient -- when a single form is submitted, the action still has to 
process and return all the forms again. You might consider a way to have the 
submissions happen via Ajax so only the submitted form has to be processed 
on the server side and updated on the client side.

Anthony

On Saturday, October 8, 2011 8:01:08 PM UTC-4, Anthony wrote:
>
> There may be other problems, but if you want to build a list of forms, you 
> need to do taglist.append(thisform). The .extend() method inserts a list 
> at the end of an existing list, and since HTML helpers act as lists with 
> respect to their components, taglist.extend(thisform) ends up inserting the 
> first (and only) component of thisform, which is the table object inside the 
> form object (so, you're getting a list of tables instead of a list of 
> forms). See if that fix helps.
>
> Anthony
>
> On Saturday, October 8, 2011 7:40:14 PM UTC-4, monotasker wrote:
>>
>> I need to present a list of edit forms, one for each tag in db.tags. I've 
>> written the controller below, but it doesn't work because (I think) the 
>> variable "thisform" is identical for each form. I think the problem is that 
>> I need to assign a unique variable name to each form (i.e., each time 
>> through the "for" loop). But since you can't use operators in a variable 
>> name, I'm not sure if this is possible. Is there a simple solution?
>>
>> tags = db(db.tags).select()
>> taglist = []
>> for tag in tags:
>>             thisform = SQLFORM(db.tags, record=tag.id, deletable = True, 
>> showid=False, fields=['tag'], labels = {'tag':''}, submit_button = 'update', 
>> delete_label = 'delete ', record_id = None, formstyle = 'table2cols', 
>> separator = '', _name=tag.tag)
>>             if thisform.accepts(request.vars, formname=tag.tag):
>>                 response.flash = 'updated'
>>             else:
>>                 response.flash = 'form has errors'
>>             taglist.extend(thisform)
>>
>

Reply via email to