It works fine.

Thanks!!

On Aug 6, 5:28 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> If a field is unchecked then it is not submitted in request.vars (that
> is how html forms work). You can use
>
> request.vars.get(field,False)
>
> or
>
> form.vars[field]
>
> (as Thadeus suggested)
>
> Massimo
>
> On Aug 6, 4:17 pm, marcelielapointe <marcelielapoi...@gmail.com>
> wrote:
>
>
>
> > Hi,
>
> > I want to acces request.vars.name_of_my_field, with
> > request.vars['name_of_my_field'] with boolean field but if the field
> > is unchecked (false) I got a KeyError like if field was not existing.
>
> > Here is an example controller:
>
> > def main():
>
> >     list_field = ['a','b','c']
>
> >     form = SQLFORM.factory(
> >         Field('a','boolean'),
> >         Field('b','boolean'),
> >         Field('c','boolean'))
>
> >     if form.accepts(request.vars,session, keepvalues=True):
>
> >         for field in list_field:
> >             print request.vars[field]
>
> >     return dict(form=form)
>
> > If I check all three field everything works fine, but if one field is
> > unchecked I got a key error when I try to access it.
>
> > It is like the field doesn't exist until it is checked..?? doesn't
> > make any sense to me...

Reply via email to