I added field type as double for those fields and that fixed, it's just strange that it didn't catch that error before.
Thank you On Thursday, December 24, 2015 at 9:07:12 AM UTC-8, Anthony wrote: > > I don't think this has anything to do with the wizard. Looks like all of > your numeric fields are defined as "string" types (which is the default > when you don't specify the "type" argument); yet your "formatter" method is > expecting float values to be coming from the database. > > Anthony > > On Thursday, December 24, 2015 at 11:05:41 AM UTC-5, aetag...@gmail.com > <javascript:> wrote: >> >> Using the form wizard, user inputs values into fields and upon completion >> of form is redirected to sqlform.grid page, where the uploaded file can be >> viewed, this all works. The problem is when I try to view the database I >> get this error: >> >> >> >> * def formatter(self,value): return '%.2f' % valueTypeError: float >> argument required, not str* >> >> This was not a problem until I implemented the form wizard, I can't >> figure out what is causing it. >> >> >> *Models:*from decimal import * >> >> class IS_MYDECIMAL(IS_DECIMAL_IN_RANGE): >> def formatter(self,value): return '%.2f' % value >> >> db.define_table('tablecosts', >> Field('yourname', 'string', requires=IS_NOT_EMPTY(), label='Your >> name:'), >> Field('thedate', 'date', requires=IS_DATE(format='%m-%d-%Y', >> error_message=T('Enter date in the format: mm-dd-yyyy')), label='Report >> date:'), >> Field('num1', requires=IS_MYDECIMAL(None,None), >> label='first:'), >> Field('num2', requires=IS_MYDECIMAL(None,None), >> label='second:'), >> Field('num3', requires=IS_MYDECIMAL(None,None), >> label='third:'), >> Field('num4', requires=IS_MYDECIMAL(None,None), >> label='fourth:'), >> ##there are a lot more fields but this is the gist of it, to keep the >> post short >> Field('costs_file', 'upload', compute=costs_calc), >> Field('created_by', 'reference auth_user', >> default=auth.user_id, readable=False, writable=False)) >> >> >> >> >> *Controller:* >> >> >> @auth.requires_login() >> def tablecosts(): >> STEPS = {0: ('yourname', 'thedate'), # fields for 1st page >> 1: ('num1', 'num2', 'num3'), # fields for 2nd page >> 2: ('num4'), #fields for 3rd >> ##this goes on for a few pages with more fields >> 6: URL('costslist')} # url when wizard completed >> step = int(request.args(0) or 0) >> if not step in STEPS: redirect(URL(args=0)) >> fields = STEPS[step] >> print "Fields: " + str(fields) + " Step " + str(step) >> if step==0: >> session.tablecosts = {} >> if isinstance(fields,tuple): >> form = SQLFORM.factory(*[f for f in db.tablecosts if f.name in >> fields]) >> if form.accepts(request,session): >> session.tablecosts.update(form.vars) >> redirect(URL(args=step+1)) >> else: >> db.tablecosts.insert(**session.tablecosts) >> session.flash = T('form completed') >> redirect(fields) >> ... > > -- 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/d/optout.