*Head slaps* Alright, I added the flash div and that bit works now. I
also removed the P() from the form and validation appears to work as
well. This all however is only working when calling the buildpage
controller function directly. When the function is brought in via
ajax, the calendar widget still doesn't work, and the form doesn't
appear to do anything other than refreshing the entire page. Any
ideas?

On Aug 20, 10:22 am, DenesL <denes1...@yahoo.ca> wrote:
> On Aug 20, 4:18 am, Alastair Medford <alastairmedf...@gmail.com>
> wrote:
>
> > 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
>
> probably there are form.errors but you are not checking for them using
> elif form.errors: ...
>
>
>
> > 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))
>
> P is not a valid container for FORM, use DIV
>
> >         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
>
> response.flash is in layout.html which you have not included with
> {{extend 'layout.html'}}
> you have to display it yourself in your view
>
> > 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.
>
> There might be more to this...
> Denes.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to