Thanks Massimo, Yes it's working now... Thousand thanks... BUT I still
don't know how I can have more control on the display of each field:
Like it's possible to load each field and display them as I want ?

- And I also wanted to know how to catch the error messages so I can
display them like I want... Like being able to get the error message
like this:
  {{if formname.errors.email:}} Email {{=formname.errors.email}}
{{pass}}

Please let me know, I feel like I don't have much flexibility for form
displayed other than putting this in the client side
"{{=LOAD('BuRegAuth', 'register', ajax_trap=True)}}  "

Thanks a lot for your help,
Yannick P.

On Mar 26, 12:02 am, mdipierro <[email protected]> wrote:
> You have two problems:
>
> 1) you are calling register twice. In index() and the LOAD callback.
> That generates two forms and confuses web2py on which one you are
> submitting. So index should just be
>
> 2) You specify onaccept both in settings and as argument of the
> register function. The latter overrides the former.
>
> Bottom line: replace this
>
> auth.settings.register_onaccept = updateInfo
> ...
> def register():
>     ...
>     return auth.register(onaccept=lambda
> form:response.headers.update({'web2py-component-
> command':"document.location='%s'"%next}))
> ...
> def index():
>     return dict(register = register())
>
> with this
>
> # auth.settings.register_onaccept = updateInfo
> ...
> def register():
>     ...
>     return auth.register(onaccept=lambda
> form:(updateinfo(form),response.headers.update({'web2py-component-
> command':"document.location='%s'"%next})))
> ...
> def index():
>     return dict()
>
> On Mar 25, 10:39 pm, Yannick <[email protected]> wrote:
>
>
>
> > Thanks.  Here is the complete action:
>
> > ############################################
> > # I'm testing the registration with Ajax and here
> > # is my simple Controller
> > ############################################
> > from applications.TestApp.modules.ControllerUtils import *
> > controlUtils = ControllerUtils(db)
>
> > # Registration Setting Information
> > auth.settings.registration_requires_verification = False
> > auth.settings.registration_requires_approval = False
>
> > def updateInfo(form):
> >     setTrue = True
> >     setFalse = False
> >     # Create a brand new album for each newly created account
> >     feedback = db.album.insert(buacct_fk = session.auth.user.id,
> >                                 albumname="Default", albumdesc="This
> > is your default Album",
> >                                albumviewprv=setFalse,
> > albumactif=setTrue)
>
> >    # Send a welcome email
> >    controlUtils.sendEmail(form.vars.email,
> >                                     'Welcome to ',
> >                                     'Enjoy the journey'
> >     )
> >     return dict()
>
> > auth.settings.register_onaccept = updateInfo
>
> > def register():
> >     auth.settings.table_user.delete_email.writable = False
> >     auth.settings.table_user.acct_frozen_cmt.writable = False
> >     auth.settings.table_user.accountFrozen.writable = False
> >     auth.settings.table_user.creationTime.writable = False
> >     auth.settings.table_user.language.writable = False
> >     auth.settings.table_user.birthday.writable = False
> >     auth.settings.table_user.delete_email.readable = False
> >     auth.settings.table_user.acct_frozen_cmt.readable = False
> >     auth.settings.table_user.accountFrozen.readable = False
> >     auth.settings.table_user.creationTime.readable = False
> >     auth.settings.table_user.birthday.readable = False
> >     auth.settings.table_user.language.readable = False
>
> >     next = URL(r=request,f='index')
> >     return auth.register(onaccept=lambda
> > form:response.headers.update({'web2py-component-
> > command':"document.location='%s'"%next}))
>
> > def index():
> >     return dict(register = register())
>
> > ########################################################
> > # The View "index.html": Very simple since i'm testing registration
> > with Ajax...
> > ########################################################
> >     <div>
> >           <br/>
> >           <br/>
> >        {{=LOAD('BuRegAuth', 'register', ajax_trap=True)}}
> >     </div>
>
> > #####
> > And also I notice that everything is displayed as textfield, How can I
> > have more control, about being able to display some fields as drop
> > down etc...
> > I also notice that this below have NO effect :
> >    - auth.settings.table_user.birthday.writable = False
> >    - auth.settings.table_user.birthday.readable = False
> > (the fields still appear in the form)
>
> > Thanks  for your help.
>
> > Yannick P.
>
> > On Mar 25, 8:49 pm, mdipierro <[email protected]> wrote:
>
> > > I think something else must be interfering with the session formkeys.
> > > I would need to look at the complete action and view.
>
> > > On Mar 25, 7:27 pm, Yannick <[email protected]> wrote:
>
> > > > Thanks for the note... But I tried it, I don't have the error anymore
> > > > but the data is not saved in the DB... I run in debug mode and put and
> > > > break point in my action "def register():" and I notice that the form
> > > > validation is not successful in the method "register()" of the Class
> > > > Auth() of "Tools.py"... I have no clue why it fails... The same value
> > > > works fine (recorded in DB) without the AJAX...
>
> > > > If you have any hint please let me know... I search a lot in the
> > > > threads of this Web2py group and I can't find an example of how to
> > > > used Auth Api with Ajax...
>
> > > > Yannick P.
>
> > > > On Mar 25, 1:19 pm, mdipierro <[email protected]> wrote:
>
> > > > > One more try
>
> > > > > def register():
> > > > >    next = URL(r=request,f='index')
> > > > >    return auth.register(onaccept=lambda
> > > > > form:response.headers.update({'web2py-component-
> > > > > command':"document.location='%s'"%next}))
>
> > > > > On Mar 25, 11:58 am, Yannick <[email protected]> wrote:
>
> > > > > > Hello thanks Massimo for the note... But I can't make it work... the
> > > > > > change_password() doesn't change the value in the DB... So I tried
> > > > > > other function just to test like "register()" and in this case i 
> > > > > > even
> > > > > > have an error message saying "TypeError: list objects are
> > > > > > unhashable"... I really don't know what I'm doing wrong up here...
> > > > > > Below it's the controller and view... Please let me know if you have
> > > > > > any idea...
>
> > > > > > #################
> > > > > > #View "index.html"
> > > > > > #################
> > > > > > .....
> > > > > > .....
> > > > > > {{=LOAD('default','register',ajax_trap=True)}}
> > > > > > .....
> > > > > > .....
> > > > > > ###################
> > > > > > #Controller: "default.py"
> > > > > > ###################
> > > > > > def register():
> > > > > >    next = URL(r=request,f='index')
> > > > > >    return auth.register(onaccept=lambda form:
> > > > > > response.headers.update({['web2py-component-
> > > > > > command']:"document.location='%s'"%next}))
>
> > > > > > def otherAction():
> > > > > >    .....
> > > > > >    .....
> > > > > >    return dict(..........)
>
> > > > > > def index():
> > > > > >    return (register = register(), otherAction=otherAction())
>
> > > > > > #########################
> > > > > > # Here is the error message
> > > > > > ########################
> > > > > > Traceback (most recent call last):
> > > > > >   File "gluon/restricted.py", line 173, in restricted
> > > > > >   File "C:/Documents and 
> > > > > > Settings/YannickT/web2py/applications/events/
> > > > > > controllers/default.py", line 70, in <module>
> > > > > >   File "gluon/globals.py", line 96, in <lambda>
> > > > > >   File "C:/Documents and 
> > > > > > Settings/YannickT/web2py/applications/events/
> > > > > > controllers/default.py", line 27, in register
> > > > > >   File "gluon/tools.py", line 1271, in register
> > > > > >   File "C:/Documents and 
> > > > > > Settings/YannickT/web2py/applications/events/
> > > > > > controllers/default.py", line 27, in <lambda>
> > > > > > TypeError: list objects are unhashable
>
> > > > > > Thanks for your help,
> > > > > > Yannick P.
>
> > > > > > On Mar 24, 10:17 pm, mdipierro <[email protected]> wrote:
>
> > > > > > > My bad
>
> > > > > > > auth.change_password(onaccept=lambda form:
> > > > > > > response.headers.update({'web2py-
> > > > > > > component-command']:"document.location='%s'"%next}))
>
> > > > > > > On Mar 24, 8:21 pm, Yannick <[email protected]> wrote:
>
> > > > > > > > Sorry but I have a lot of syntax error in the action:
>
> > > > > > > > auth.change_password(onaccept=lambda form: 
> > > > > > > > response.headers['web2py-
> > > > > > > > component-command']="document.location='%s'"%next))
>
> > > > > > > > I don't seems to see why... Please let me know if you see it...
> > > > > > > > Thanks,
>
> > > > > > > > On Mar 24, 2:00 pm, mdipierro <[email protected]> wrote:
>
> > > > > > > > > ###################################################
> > > > > > > > > <script>
> > > > > > > > >   $("#pwdChangeForm").submit(function(){
> > > > > > > > >    url={{=URL(r=requet, f="changePwd")}};
> > > > > > > > >    ids = ['currentpwd', 'pwd1', 'pwd2'];
> > > > > > > > >    ajax(url, ids, 'confirmationMsg');   # This is the Ajax 
> > > > > > > > > method that
> > > > > > > > > is coming with Web2py
> > > > > > > > >    return false;
>
> > > > > > > > > });
>
> > > > > > > > > </script>
>
> > > > > > > > > In view:
> > > > > > > > > {{=LOAD('defualt','changePwd',ajax_trap=True)}}
>
> > > > > > > > > ######################################
> > > > > > > > > # Action: (Here I want to use the Auth method named 
> > > > > > > > > change_password. )
> > > > > > > > > ##############################
> > > > > > > > > def changePwd:
> > > > > > > > >    next = URL(r=request,f='index')
> > > > > > > > >    return auth.change_password(onaccept=lambda form:\
> > > > > > > > >        response.headers['web2py-component-
> > > > > > > > > command'="document.location='%s'" % next)
>
> > > > > > > > > On Mar 24, 12:22 pm, Yannick <[email protected]> wrote:
>
> > > > > > > > > > Ok here is a view form to change user password:
> > > > > > > > > > ###################################################
> > > > > > > > > > <script>
> > > > > > > > > >   $("#pwdChangeForm").submit(function(){
> > > > > > > > > >    url={{=URL(r=requet, f="changePwd")}};
> > > > > > > > > >    ids = ['currentpwd', 'pwd1', 'pwd2'];
> > > > > > > > > >    ajax(url, ids, 'confirmationMsg');   # This is the Ajax 
> > > > > > > > > > method that
> > > > > > > > > > is coming with Web2py
> > > > > > > > > >    return false;});
>
> > > > > > > > > > </script>
>
> > > > > > > > > > <div id="confirmationMsg"></div>
> > > > > > > > > > <form id="pwdChangeForm"  method="post">
> > > > > > > > > >     Current password:    <input type="password" 
> > > > > > > > > > id="currentpwd"
> > > > > > > > > > name="currentpassword">
> > > > > > > > > >     new password:      
>
> ...
>
> read more »

-- 
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.

Reply via email to