Hi, both version do save a None (actually all form.accepts, FORM.accepts, SQLFORM.accepts do).
Wouldn't be the correct behavior to consistently and always convert a False value to 'F'? Am I missing something? Thanks a lot! Frederik On Wed, Jan 27, 2010 at 4:59 PM, mdipierro <[email protected]> wrote: > On a second look I believe FORM.accepts behave correctly. Since it is > not supposed to convert None to 'F'. Only SQLFORM.accepts does that. > > On Jan 27, 8:24 am, mdipierro <[email protected]> wrote: >> Why >> >> def test1(): >> form=SQLFORM.factory(Field("bool","boolean")) >> >> if FORM.accepts(form, request.vars, session, keepvalues=True): >> db.test.insert(bool=request.vars.bool) >> >> return dict(form=form,list=db().select(db.test.ALL)) >> >> and not >> >> def test1(): >> form=SQLFORM.factory(Field("bool","boolean")) >> >> if form.accepts(request.vars, session, keepvalues=True): >> db.test.insert(bool=request.vars.bool) >> >> return dict(form=form,list=db().select(db.test.ALL)) >> >> ? >> >> Please check the latter, it should work fine. I check why the former >> does not. >> >> On Jan 27, 1:50 am, Frederik Wagner <[email protected]> wrote: >> >> > Hi .*, >> >> > it seems to me that there is a bug saving boolean fields with >> > SQLFORM.factory forms. >> > If I define a boolean field in a table and use the standard SQLFORM to >> > make an input form, the accept function will save 'T' of 'F' to the >> > DB. >> > Whereas in the case where I create a form with SQLFORM.factory, do a >> > FORM.accept and an explicit db.insert, instead of 'F' there will be a >> > NULL on the DB. >> >> > Here a test setup: >> >> > DB: >> > db.define_table('test',Field('bool','boolean')) >> >> > CONTROLLER: >> > def test1(): >> > form=SQLFORM.factory(Field("bool","boolean")) >> >> > if FORM.accepts(form, request.vars, session, keepvalues=True): >> > db.test.insert(bool=request.vars.bool) >> >> > return dict(form=form,list=db().select(db.test.ALL)) >> >> > def test2(): >> > form=SQLFORM(db.test) >> >> > if form.accepts(request.vars, session, keepvalues=True): >> > response.flash = 'done' >> >> > return dict(form=form,list=db().select(db.test.ALL)) >> >> > test1 gives 'True' ('T') and 'None' (NULL) and test2 'True' ('T') and >> > 'False' ('F'). >> >> > A bug or my problem? :-) >> >> > Bye >> > Frederik >> >> > > -- > 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. > > -- 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.

