[web2py] Re: dynamic SQLForm.factory from query

2012-01-17 Thread Annet
Did you have a look at the wiki example in the web2py book:
http://www.web2py.com/books/default/chapter/29/3#A-wiki ?

Instead of a 'page' table you have the table from which you retrieve
the list and, just like in the example, a table to store the comments.
page_id in your case becomes list_id.

I don't see why you need the fields and counter variable. I would move
the for loop to the view and do something like:

{{for row in rows:}}
  
{{=row.field_name}}
{{=A('Add comment',_href=URL('addComment',args=row.id))}}
  
{{pass}}


.. and in the addComment function something like:


db.comment.list_id.default=request.args(0)
form=crud.create(table=db.comment)


I hope this helps you solve the problem.


Kind regards,

Annet


[web2py] Re: dynamic SQLForm.factory from query

2012-01-18 Thread web-dev-m
Awesome.  So easy, I dont know why I didnt think of that.  Thank you.

On Jan 18, 1:57 am, Annet  wrote:
> Did you have a look at the wiki example in the web2py 
> book:http://www.web2py.com/books/default/chapter/29/3#A-wiki?
>
> Instead of a 'page' table you have the table from which you retrieve
> the list and, just like in the example, a table to store the comments.
> page_id in your case becomes list_id.
>
> I don't see why you need the fields and counter variable. I would move
> the for loop to the view and do something like:
>
> {{for row in rows:}}
>   
>     {{=row.field_name}}
>     {{=A('Add comment',_href=URL('addComment',args=row.id))}}
>   
> {{pass}}
>
> .. and in the addComment function something like:
>
> db.comment.list_id.default=request.args(0)
> form=crud.create(table=db.comment)
>
> I hope this helps you solve the problem.
>
> Kind regards,
>
> Annet