When I send my registration form I get the error below from the
controller: controllers/default.py
What should I do to be able to send the form and save form data into
database?

Line 17 in default.py refers to:

    form=auth()

Do I have to add some code yet to user function to be able to send my
form?
I Add that when I send login form it works FINE!

--------------------------------------------------------------------------------------------------------------------------------------
Error traceback

Traceback (most recent call last):
  File "gluon/restricted.py", line 178, in restricted
  File "F:/Programy/web2py/applications/myapplication/controllers/
default.py", line 44, in <module>
  File "gluon/globals.py", line 96, in <lambda>
  File "F:/Programy/web2py/applications/myapplication/controllers/
default.py", line 17, in user
  File "gluon/tools.py", line 966, in __call__
  File "gluon/tools.py", line 1502, in register
  File "gluon/sqlhtml.py", line 876, in accepts
  File "gluon/html.py", line 1452, in accepts
  File "gluon/html.py", line 480, in _traverse
  File "gluon/html.py", line 480, in _traverse
  File "gluon/html.py", line 480, in _traverse
  File "gluon/html.py", line 480, in _traverse
  File "gluon/html.py", line 487, in _traverse
  File "gluon/html.py", line 1245, in _validate
  File "gluon/validators.py", line 453, in __call__
  File "gluon/sql.py", line 1592, in __getitem__
KeyError: 'login'



# -*- coding: utf-8 -*-

#########################################################################
## This is a samples controller
## - index is the default action of any application
## - user is required for authentication and authorization
## - download is for downloading files uploaded in the db (does
streaming)
## - call exposes all registered services (none by default)
#########################################################################

def index():
    response.flash = T('Welcome to web2py')
    return dict(message=T('Hello World'))


def user():
    form=auth()
    return dict(form=form)


def call():
    session.forget()
    return service()


def download():
    """
    allows downloading of uploaded files
    http://..../[app]/default/download/[filename]
    """
    return response.download(request,db)


def page2():
    name = request.vars.login
    #db.auth_user.insert(name=name)
    return dict(name=name)


def ajaxuserexist():
      username = request.vars.values()[0]
      return  db(db.auth_user.username==username).count() and 'yes' or
'no'

response._vars=response._caller(user)




On 24 Lip, 00:55, "mr.freeze" <[email protected]> wrote:
> Sorry, that's <tr><td>{{=lbl.username}}:</td><td>{{=wdgt.username}}</
> td></tr>
>
> On Jul 23, 5:16 pm, "mr.freeze" <[email protected]> wrote:
>
> > I noticed that some of your table is malformed.
> > <tr>{{=lbl.username}}:<td>{{=wdgt.username}}</td></tr>
> > should be
> > <tr><td>{{=lbl.username}}:<td/><td>{{=wdgt.username}}</td></tr>
>
> > There are several like this. Make sure all of your table content is in
> > td's then try again.
>
> > On Jul 23, 5:13 pm, elfuego1 <[email protected]> wrote:
>
> > > I had removed this part of the code but it's not working anyway.
> > > Answering your quetion: I can see the button but it's not wroking as
> > > it should.
>
> > > On 23 Lip, 19:47, "mr.freeze" <[email protected]> wrote:
>
> > > > Are you not seeing thesubmitbutton or is it just not working? I see
> > > > in your javascript that you are basically cancelling thesubmitwith
> > > > this code:
> > > >  varsubmit= false;
> > > >     $(document).ready(function(){
> > > >         $("form").submit(function() {
> > > >             returnsubmit;
> > > >         });
> > > >     });
>
> > > > On Jul 23, 12:37 pm, elfuego1 <[email protected]> wrote:
>
> > > > > Can I count on some help?
>
> > > > > On 23 Lip, 15:50, elfuego1 <[email protected]> wrote:
>
> > > > > > Firstsubmitbutton on login page works like a charm.
> > > > > > Butsubmitbutton on registration page - doesn't.
>
> > > > > > Content of my user.html
> > > > > > ---------------------------------------------------------------------------
>
> > > > > > {{extend 'layout.html'}}
>
> > > > > > {{lbl=form.custom.label}}
> > > > > > {{wdgt=form.custom.widget}}
>
> > > > > > {{if request.args(0)=='login':}}{{#=auth.login()}}
> > > > > > {{=form.custom.begin}}
> > > > > > <table>
> > > > > >     <tr>{{=lbl.username}}:<td>{{=wdgt.username}}</td></tr>
> > > > > >     <tr>{{=lbl.password}}:<td>{{=wdgt.password}}</td></tr>
> > > > > > </table>
> > > > > > {{=form.custom.submit}}
> > > > > > {{=form.custom.end}}
>
> > > > > > {{elif request.args(0)=='register':}}
> > > > > > {{=form.custom.begin}}
> > > > > >     <table>
> > > > > >         <tr>
> > > > > >             <label for="register_login">{{=lbl.username}}</label>
> > > > > >             <td><input type="text" id="username" name="username"
> > > > > > onblur="getData(this.value)" /></td>
> > > > > >             <td><div id="resultbox" class="msg"></div></td>
> > > > > >         <tr>
> > > > > >             <label for="password"
> > > > > > id="auth_user_password">{{=lbl.password}}</label>
> > > > > >             <td>{{=wdgt.password}}<td>
> > > > > >         </tr>
> > > > > >         <tr>
> > > > > >             <label for="register_first_name" >{{=lbl.first_name}}</
> > > > > > label>
> > > > > >             <td>{{=wdgt.first_name}}</td>
> > > > > >         </tr>
> > > > > >         <tr>
> > > > > >             <label for="register_last_name" >{{=lbl.last_name}}</
> > > > > > label>
> > > > > >             <td>{{=wdgt.last_name}}</td>
> > > > > >         </tr>
> > > > > >         <tr>
> > > > > >             <label for="register_email" >{{=lbl.email}}</label>
> > > > > >             <td>{{=wdgt.email}}</td>
> > > > > >         </tr>
> > > > > >         <tr>
> > > > > >             <label for="register_phone" >{{=lbl.phone_no}}</label></
> > > > > > th>
> > > > > >             <td>{{=wdgt.phone_no1}}</td>
> > > > > >         </tr>
> > > > > >     <table>
> > > > > > {{=form.custom.submit}}
> > > > > > {{=form.custom.end}}
> > > > > > {{pass}}
>
> > > > > > additionaly layout.html incluedes also this:
> > > > > > ---------------------------------------------------------------------------------------------------------
>
> > > > > > <script type="text/javascript"
> > > > > > src="{{=URL(r=request,c='static',f='jquery.js')}}"></script>
> > > > > >     <script type="text/javascript">
>
> > > > > >     varsubmit= false;
> > > > > >     $(document).ready(function(){
> > > > > >         $("form").submit(function() {
> > > > > >             returnsubmit;
> > > > > >         });
> > > > > >     });
>
> > > > > >     function getData(value){
> > > > > >         if(value != ""){
> > > > > >             $
> > > > > > ("#resultbox").removeClass().addClass('msg').text('Validating...').fadeIn(100);
> > > > > >             
> > > > > > $.post("{{=URL(r=request,c='default',f='ajaxuserexist')}}",
> > > > > > {username:value},function(result){
> > > > > >                 if(result=='yes'){
> > > > > >                     $
> > > > > > ("#resultbox").removeClass().addClass('error').text('Username 
> > > > > > already
> > > > > > taken').fadeTo(900,1);
> > > > > >                    submit= false;
> > > > > >                 }else{
> > > > > >                     $
> > > > > > ("#resultbox").removeClass().addClass('success').text('Username is
> > > > > > available for registration!').fadeTo(900,1);
> > > > > >                    submit= true;
> > > > > >                 }
> > > > > >             });
> > > > > >         }else{
> > > > > >             $("#resultbox").removeClass().addClass('msg').text('This
> > > > > > field is required');
> > > > > >         }
> > > > > >     }
>
> > > > > >     </script>
>
> > > > > > This is used for on the fly username checking in the DB.
>
> > > > > > On 23 Lip, 15:14, mdipierro <[email protected]> wrote:
>
> > > > > > > Please show us the form and the customization. 
> > > > > > > {{=form.custom.submit}}
> > > > > > > should just produce <input type="submit"/>. The problem is 
> > > > > > > somewhere
> > > > > > > else.
>
> > > > > > > On Jul 22, 6:37 pm, elfuego1 <[email protected]> wrote:
>
> > > > > > > > Hi,
>
> > > > > > > > I had made mycustomform, but adding {{=form.custom.submit}} 
> > > > > > > > doesn't
> > > > > > > > let me send the form.
> > > > > > > > How should I addsubmitbutton to the page, so I would get a 
> > > > > > > > default
> > > > > > > > fields validation and formsubmitfunctionallity?
>
> > > > > > > > Best regards.

Reply via email to