There are two issues

1) when form is submitted variables go in request.post_var and
request.vars not int request.get_vars
2)

when request.vars.DefaultTrue!=None => form.vars.defaultTrue==True
when request.vars.DefaultTrue==None => form.vars.defaultTrue==False

This is off but request.vars follows HTML conventions, form.vars
follows database convention.



On Feb 22, 3:10 pm, Peter Woolf <[email protected]> wrote:
> Hi All,
>
> I'm trying to make a simple boolean form that upon submission puts the
> form data into the URL, and in doing so defines the  states of each
> button.  Unfortunately this is not working, for reasons I can't see.
>
> In the code below, the button first defaults to checked.  If the
> button is deselected, then on redirect the button is off (as
> expected).  BUT, if the form is submitted a second time, the button is
> turned back on again, and locked on forever no matter what I do.
>
> I suspect that this is happening because when the button is not
> pushed, the form.vars.DefaultTrue=None, but oddly it seems this gets
> translated to "True" in the URL.  I never get "None" in
> request.get_vars.DefaultTrue.   I can't figure out how to change this.
>
> I know I can use keepvalues=True to prevent this for a single session,
> but it then does not use the data in the URL.
>
> Am I doing something wrong here?
>
> Thanks,
>
> --Peter
>
> -------------
>
> def test_boolean_forms():
>   default_val=True
>   if request.get_vars.DefaultTrue=="False":
>     default_val=False
>   form=SQLFORM.factory(Field("DefaultTrue","boolean", default=default_val))
>   if form.accepts(request.vars, session):
>     redirect(URL(r=request,f='test_boolean_forms',vars=form.vars))
>   return dict(form=form)

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to