The idea was that after a comment is accepted and saved to the DB the user will be returned to the view_post() controller which will update the page so they can see the comment they just posted. I assumed that because I put view_post() under the if form.process().accepted: it would only be called when the form is submitted, is this not correct?
I also assumed that because I generated the form in the comment_form() action that it would it's self become the form action not the view_post() action. I understand that view_post() has not arguments. I only put this in here to remind myself that I needed to find a way of passing back to view_post() the id of the record that I need to pull out the database. I was thinking that I would redirect and create a url back to the view_post() action. So there are a lot of assumptions there. Can help me in understanding how I should collect a comment and then return back to the view_post() action, because I still cant understand why the form action is empty when I view source. Simon On 20 August 2012 22:56, Anthony <[email protected]> wrote: > Given this section of my controller, you will see that in view_post(), I >> am calling comment_form() to generate a form and return it back so I can >> include it in the view_post.html. The form displays fine in the view but >> the when I view the source the action ="" so it does not post anywhere. >> What am I doing wrong? >> > > It should post to the view_post action, which will again call > comment_form, which should then process the submitted form. > > >> def comment_form(post_id): >> db.comments.post_id.default = post_id >> form = SQLFORM(db.comments) >> if form.process().accepted: >> response.flash = "Comment saved" >> view_post(form.vars.post_id) >> > > What is view_post(form.vars.post_id) supposed to do? You cannot call > view_post() with any arguments because it doesn't take any. You're also > calling view_post() recursively. > > Anthony > > -- > > > > --

