Hello All,
The *design *is: I have a custom form with the a controller that 
inserts/updates a table. Tthe form accepts data, and on successful 
submission of this form, it stays on the same page (there are no redirects 
to another page or form)
*Issue*: The problem am seeing is, when I update values in the form, and 
submit it, the entered values are lost when the form returns because of 
successful submit, or due to errors. I have tried to use keepvalues=True in 
the form.accepts() and form.process() methods. No luck.
Details below.

Since the page am building has specific design needs, I went with the 
option of a custom form, where I used the form.custom.* options quite a 
bit. Therefore input fields in the form look like this
 <input type="text" class="form-control 
                   {{if form.errors.country:}}invalidinput{{pass}}"
                    id="country" name="country" 
                    value="{{=form.custom.inpval['country']}}"
                    placeholder="{{=form.custom.comment['country']}}"

Also the controller is coded as below
    x = db(db.x.x_id == auth.user.id).select().first()
    if x:
        form = SQLFORM(db.x, record=x)
    else:
        form = SQLFORM(db.x)
    pass

 
    # process the form
    if form.accepts(request.vars, formname='basicinfo_form', keepvalues=True
):
        response.flash = 'Basic Information updated successfully.'
    elif form.errors:
        response.flash = 'The submitted form contains errors. The fields in 
error are highlighted below.'
    else:
        response.flash = 'Please fill the form.'
    pass

    return dict(form=form)

I was thinking that maybe I should capture the request.vars and send it 
back to the view alongwith the form. 
If the request.vars.country value exists, then I use that, instead of the 
form.custom.inpval['country']. This only makes the view code a bit more 
verbose, but if it solves the problem, then nothing like it. 

Can anyone suggest what I could do to sort this out?
Thank you,
Kiran

P.S: I did take a look at all the conversations in the forum about 
keepvalues. None of them seemed to help me. Though I did find this one to 
be interesting and am curious if this is sorted out already: 
https://groups.google.com/forum/#!searchin/web2py/keepvalues$20on$20validate/web2py/MNEYo96Shzg/jjKZaMmfAgQJ

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to