> > I was just thinking, would it not be smarter to have a FORM helper with an > ajax option?
> something like this: > > FORM(ajax=True, eval=True, target='targetdiv/object') > It probably makes most sense to do an Ajax form when you've got multiple items on the page and don't want to refresh the whole page just to submit the form. But in that case, it is probably generally better for the form to have its own dedicated action, in which case, you can just put it in a component using the LOAD() helper, with either ajax=True or ajax_trap=True. See http://web2py.com/books/default/chapter/29/12#Components. To be honest almost half of my form posts are ajax now, so it feels wiered > that I can not just choose if it is ajax when creating the form with the > FORM helper. And the reason I do not do it more is because of the overhead > and complexity of the code that increases for every form I need to write. I > would even like to have a crud.create form that I could choose as an ajax > form reducing ajax forms to a couple of lines of code in my controler > instead of writing them in the view. Keep in mind that if the framework doesn't do something, nothing is stopping you from writing your own helper to minimize code repetition. If there are cases where using LOAD() doesn't solve your problem, you could always write a simple helper function (not tested): def ajaxify(form, action=None, target=None): action = URL(args=request.args, vars=request.vars) if not action elseaction id = form.formname if hasattr(form, 'formname') else 'ajax_form' target = id if not target else target form.element('input[type=submit]')['_onclick'] = \ 'ajax("%s", "#%s form", "%s"); return false;' % (action, id, target) return DIV(form, _id=id) You could also subclass FORM and implement the above in the new class. Anthony -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.