On Sunday, January 28, 2018 at 10:37:40 AM UTC-5, Alfonso Serra wrote:
>
> Sorry this would be the controller, the previous case was not ajax but a
> normal post.
>
> def index():
>
> tbl = request.args(0)
> table = ""
>
> id = request.post_vars.id
> delete = False
> if request.post_vars and id:
> if request.post_vars.delete:
> request.post_vars.pop("delete")
> delete = True
>
> # do not delete fields data if not present in post_vars
> fields = [fld for fld in request.post_vars.keys() if fld not in [
> "_formkey","_formname"]]
> form = SQLFORM(db[tbl], id, fields=fields).process(formname=tbl)
> else:
> form = SQLFORM(db[tbl]).process(formname=tbl)
>
> msg = "None"
>
> if form.accepted:
> msg = "All good"
> if delete and form.record:
> form.record.delete_record()
> elif form.errors:
> msg = "Errors"
> print form.errors
>
> print form.accepted, form.errors
> if request.ajax:
> if form.errors:
> raise HTTP(406, json.dumps(form.errors))
> newkey = form.formkey
> return newkey;
>
> table = DataTable(form)
>
> return locals()
>
> The explanation would be that Datatable is also calling the widget to
> parse the datetime format.
>
> So a row is submitted from the view, the form calls the widget as text,
> the DataTable calls it a second time, and the form submission would it be
> the third?
>
Don't know, as you haven't shown the code for DataTable nor the view.
Probably something like that, though.
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.