>From the book: form = SQLFORM(...,hidden=...)
causes the hidden fields to be passed with the submission, no more, no less. form.accepts(...) is not intended to read the received hidden fields and move them into form.vars. The reason is security. Hidden fields can be tampered with. So you have to explicitly move hidden fields from the request to the form: 1 2 form.vars.a = request.vars.aform = SQLFORM(..., hidden=dict(a='b')) Unfortunately, the code in that last example is incorrect -- line 1 should go *after* line 2. So, you can add values from request.vars to form.vars before calling .validate() or .process(), and the values will be available in any onvalidation callback (of course, you can also refer directly to request.vars anywhere). Anthony On Monday, August 27, 2018 at 12:37:57 AM UTC-4, Joe Barnhart wrote: > > So I'm trying to use a hidden field to create some unique behavior in a > form. I want to send out the field when the form is first created (using > the hidden=dict(...) keyword on SQLFORM). But later, while processing the > form through the error phase, I want to update that value to a different > value using a "form.vars" or "request.post.vars" kind of mechanism. But > form.vars does not have hidden fields, and putting in a matching value for > my hidden field is ignored when the form is passed back. > > I can't change its value in the SQLFORM() process because the new value of > the field is only known AFTER form creation and submission. When it comes > back, THEN I know what I want the value to be, but by this time the SQLFORM > method has re-run and the value of the hidden field is fixed. > > I'd like something like: > > form = SQLFORM(.... hidden=dict(a='b') > . . . > if form.validate(): > . . . > elif form.errors: > form.var.a = 'c' > > What am I missing? Are hidden fields dumb, one-way-trip only fields? Are > they not modifiable along with the other fields? > > -- Joe > > -- 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.

