Try form.vars instead.

--
Thadeus





On Fri, Aug 6, 2010 at 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