You fall on an empty "name" vars... Could you have forget to pass the name vars throught url?
Richard On Fri, Feb 26, 2016 at 3:14 PM, <aetagot...@gmail.com> wrote: > Can someone please tell me why I am getting this error and how to fix it? > > > numpatients = int(request.vars.name); > <type 'exceptions.TypeError'> int() argument must be a string or a number, > not 'NoneType' > > *db.py* > > > db.define_table('post', > Field('patient'), > Field('attime'), > Field('age') > ) > > *view.html* > > *index.html* > > <form enctype="multipart/form-data" action="{{=URL('default', > 'postform')}}" method="post"> > How many patients?: <input name="name"/> <input type="submit"/> > </form> > > > > *postform.html* > > {{=BEAUTIFY(form)}} > > > *controller.py* > > > def postform(): > inputs = []; > numpatients = int(request.vars.name); > for i in range(0, numpatients): > inputs.append(db.post.patient.clone(name='%s_%s' % ( > db.post.patient.name, i))) > inputs.append(db.post.attime.clone(name='%s_%s' % ( > db.post.attime.name, i))) > inputs.append(db.post.age.clone(name='%s_%s' % (db.post.age.name, > i))) > form = SQLFORM.factory(*inputs) > if form.process().accepted: > for i in range(0,numpatients): > db.post.insert(post=form.vars['patient_%s' % i]) > db.post.insert(post=form.vars['attime_%s' % i]) > db.post.insert(post=form.vars['age_%s' % i]) > elif form.errors: > response.flash = 'form has errors' > return dict(form=form) > > > > > I want to prompt the user to enter a value of how many patients to enter > for the session, they are redirected to a page where a single form is > displayed and there are multiple form field instances displayed based on > the number of patients they want to enter for that session. When I click > submit after filling the form, I keep getting that error and I don't > understand why or how to change it because I need that value from the > previous page to know how many form field instances to display. > > -- > 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. > -- 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.