Thanks Massimo for the note, I really appreciate your help... Now I
have more control on the layout using your latest change thx... BUT
there are few problems... the "next " doesn't seems to work.... I
have to do this:
1)
- auth.settings.register_next= URL(r=request,c='controller',
f='index') to actually go where I want to go right after a successful
registration...
If i only do this in the action :
- next = URL(r=request,c='controller', f='index')
return dict(form=auth.register(onaccept=lambda form:
(updateInfo(form),response.headers.update({'web2py-component-
command':"document.location='%s'"%next}))))
After a registration the page will be redirect to "http://
127.0.0.1:8000/App/default/index"...
2)
Also for the login using Auth and Ajax, when I enter a username and
fake password the page is also redirect to "http://127.0.0.1:8000/App/
default/index". (I put the code to handle the error, I wonder why the
page get redirect instead of returning an error msg)
3)
Also for the registration, when there is an error in the registration
form, I handle the errors BUT the form returned is empty... i was
wondering how to keep the data in the form returned when there is an
error... something like "Keepvalue= true"... I hope you understand
what I mean...
Thanks and please let me know if you have any idea,
Yannick P.
On Mar 30, 9:35 pm, mdipierro <[email protected]> wrote:
> One more try.. closer to the solutions...
>
> view as before and action
>
> def register():
> ...
> next = URL(r=request,f='index')
> return dict(form=auth.register(onaccept=lambda form:
> (updateInfo(form),response.headers.update({'web2py-component-
> command':"document.location='%s'"%next}))))
>
> On Mar 30, 8:06 pm, Yannick <[email protected]> wrote:
>
>
>
> > Thanks for the note.... I followed your instructions step by step
> > unfortunately even this solution doesn't work... the Action dictate
> > the display, I have NO control on the view...
>
> > #
> > #here is the view Register.html:
> > #
>
> > {{=form.custom.begin}}
> > Full Name: <input class="string" id="auth_user_fullname"
> > name="fullname" type="text" value="" />
> > Email: <input class="string" id="auth_user_email" name="email"
> > type="text" value="" />
> > Password: <input class="password" id="auth_user_password"
> > name="password" type="password" value="" />
> > Verify Pwd: <input name="password_two" id="auth_user_password_2"
> > type="password" />
> > <input type="submit" value="Submit" />
> > {{=form.custom.end}}
>
> > #
> > # Here is the action
> > #
> > def register():
> > ...
> > next = URL(r=request,f='index')
> > return auth.register(onaccept=lambda form:
> > (updateInfo(form),response.headers.update({'web2py-component-
> > command':"document.location='%s'"%next})))
>
> > Whatever I enter in the view will not be display NOTHING, only the
> > registration form return from the action will be displayed... It's
> > like the form from the action override everything html code I
> > enter...
>
> > I'm kind of desperate... If you have any other idea please let me
> > know... Or if you know a place where there is a working example please
> > send me a link... In the meantime I'll just drop this Auth API -
> > Ajax...
>
> > Thanks a lot for your help...
> > Yannick P.
>
> > On Mar 27, 8:36 pm, mdipierro <[email protected]> wrote:
>
> > > IF, as I assume, the register action is called via the
> > > {{=LOAD('controller','register')}} helper THEN
>
> > > there should be no ajax handling in register.html. It should just be:
>
> > > {{=form.custom.begin}}
> > > Full Name: <input class="string" id="auth_user_fullname"
> > > name="fullname" type="text" value="" />
> > > Email: <input class="string" id="auth_user_email" name="email"
> > > type="text" value="" />
> > > Password: <input class="password" id="auth_user_password"
> > > name="password" type="password" value="" />
> > > Verify Pwd: <input name="password_two" id="auth_user_password_2"
> > > type="password" />
> > > <input type="submit" value="Submit" />
> > > {{=form.custom.end}}
>
> > > Moreover all the INPUT fields in the custom form must have names as
> > > the corresponding fields in auth_user table and all required fields i
> > > auth_user MUST be present in the custom form.
>
> > > Moreover since you form is using
> > > <input class="string" id="auth_user_fullname" name="fullname"
> > > type="text" value="" />
> > > instead of {{=form.custom.widget.fullname}} (assuming you do have a
> > > field called fullname, which is not there in the default) you will
> > > have to handle manually all error reporting.
>
> > > On 27 Mar, 10:10, Yannick <[email protected]> wrote:
>
> > > > Hello Massimo, First thanks for you help... I'm stil not successful
> > > > with customizing the form for Auth Api using Ajax. Please let me know
> > > > what I'm doing wrong... Here is my view and controller (I did not
> > > > extend Layout.html)
>
> > > > #############
> > > > # Register.html
> > > > ##############
> > > > <html>
> > > > <script>
> > > > $('#regForm').submit(function(){
> > > > url = "{{=URL(r=request, f='register')}}";
> > > > ids = [ 'auth_user_fullname', 'auth_user_email',
> > > > 'auth_user_password', 'auth_user_password_2' ];
> > > > ajax(url, ids , 'registerMsg');
> > > > });
>
> > > > // I took this from Web2py_ajax just for testing this Register
> > > > function ajax(u,s,t) {
> > > > var query="";
> > > > for(i=0; i<s.length; i++) {
> > > > if(i>0) query=query+"&";
> > > > query=query+encodeURIComponent(s[i])
> > > > +"="+encodeURIComponent(document.getElementById(s[i]).value);
> > > > }
> > > > jQuery.ajax({type: "POST", url: u, data: query, success:
> > > > function(msg) { if(t==':eval') eval(msg); else
> > > > document.getElementById(t).innerHTML=msg; } });}
>
> > > > </script>
>
> > > > <div id="registerMsg"> </div>
> > > > <div>
> > > > <form action="" id="regForm" enctype="multipart/form-data"
> > > > method="post">
> > > > Full Name: <input class="string" id="auth_user_fullname"
> > > > name="fullname" type="text" value="" />
> > > > Email: <input class="string" id="auth_user_email" name="email"
> > > > type="text" value="" />
> > > > Password: <input class="password" id="auth_user_password"
> > > > name="password" type="password" value="" />
> > > > Verify Pwd: <input name="password_two" id="auth_user_password_2"
> > > > type="password" />
> > > > <input type="submit" value="Submit" />
> > > > </form>
> > > > </div>
>
> > > > </html>
>
> > > > ##############
> > > > # Controller
> > > > ##############
>
> > > > def register():
> > > > auth.settings.table_user.last_name.writable=False
> > > > auth.settings.table_user.last_name.readable=False
>
> > > > next = URL(r=request,f='index')
> > > > return auth.register(onaccept=lambda form:
> > > > (updateInfo(form),response.headers.update({'web2py-component-
> > > > command':"document.location='%s'"%next})))
>
> > > > #########################
>
> > > > When doing this my view has no control on the display, it's like the
> > > > form return from the register Action overwritte everything... Can you
> > > > please let me know when I'm wrong here...
> > > > Thanks,
> > > > Yannick P.
--
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.