What I am trying to do is create a controller function that can be called via ajax and returns some html content along with an SQLFORM. I've got the content and form to appear on the page, but the SQLFORM doesn't work as it should. When I submit information from the view that the generated content has been placed into, the page refreshes and nothing has been inserted into the database. The calendar widget for the date field in the form also does not work. When I call the controller function directly, the calendar widget works fine and the data submits to the database properly. Here is my controller code:
def buildPage(): content = [] data = xmltools.getData('blah') template = xmltools.getTemplate(data.tag) for i in template: if i.tag == "header": content.append(H1(i.text)) elif i.tag == "label": content.append(P(i.text)) elif i.tag == "database": form = SQLFORM(db[i.text]) content.append(P(form)) else: content.append(i.tag) if form.accepts(request.vars,session): response.flash='new record inserted' return response.render('default/form.html',dict(page=DIV (*content))) and in default/form.html: {{include 'web2py_ajax.html'}} {{=page}} The response.flash also does not work in either circumstance, nor does form validation. Is this at all the right way I should be approaching this? I've found posts that do similar things to what I'm trying to do, but nothing seems to complete the picture. Looking ahead I also think I may have a problem with how validation is handled by default. I believe the way SQLFORM reports errors is to refresh the entire page and do something similar to response.flash. If I want just the ajaxed div to refresh and not the entire page, how would I do this with SQLFORM, if it's even possible? As always, any insight is appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---