[web2py] Re: keepvalues - need help with this

2014-01-13 Thread subbaraman . kiran
Massimo,
Yes, I did. Does not make a difference. 

Thanks for the suggestion,
Kiran

On Monday, January 13, 2014 7:49:15 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Have you tried replacing
>
> value="{{=form.custom.inpval['country']}}"
>
> with
>
> value="{{=form.custom.dspval['country']}}"
>
> On Sunday, 12 January 2014 22:50:43 UTC-6, subbaram...@gmail.com wrote:
>>
>> Really would like some help with this. Anyone have suggestions?
>> Thank you,
>> Kiran
>>
>> On Saturday, January 11, 2014 12:10:07 AM UTC+5:30, 
>> subbaram...@gmail.comwrote:
>>>
>>> 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
>>>  >> 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.


[web2py] Re: keepvalues - need help with this

2014-01-12 Thread subbaraman . kiran
Really would like some help with this. Anyone have suggestions?
Thank you,
Kiran

On Saturday, January 11, 2014 12:10:07 AM UTC+5:30, subbaram...@gmail.com 
wrote:
>
> 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
>   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.


[web2py] keepvalues - need help with this

2014-01-10 Thread subbaraman . kiran
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
 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.


[web2py] R/W restrictions specific to a form

2013-11-07 Thread subbaraman . kiran
Hello All,
I have these two tables
db.auth_user - which is the default table created for Auth
email, password, first name, last name

db.b
b0, b1, b2, b3

db.b.b0 foreign-key linked to db.auth_user.id 

My requirement: Display only fields first name, last name, b2, b3. Updates 
can only happen to these fields, and no other. I do not want the password, 
or email fields to be displayed, because I want to use the default change 
password form to change passwords. 

I experimented with
form = SQLFORM.factory(db.auth_user, db.b)
if form.process().accepted:
id = db.auth_user.insert(**db.auth_user._filter_fields(form.vars)) # 
this needs to be corrected to accept only first and last names.
form.vars.b = id
id = db.b.insert(**db.b._filter_fields(form.vars))


Wasn't sure how to explicitly restrict writes to certain fields, only for 
this form. It is possible that these fields need to be updated from a 
different form.
I had a look at this discussion on the forum, and it helped me understand 
this a bit better, but not sure it helps my case: 
https://groups.google.com/forum/#!topic/web2py/qd6blGfnVTA
Also, factory seems to create a SQLFORM which does not work with the 
database(?). So, am not sure how to proceed on this one. 


Kiran Subbaraman
http://subbaraman.wordpress.com/about/



-- 
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.