Hmm, I tried the code you provided below (with ajax=True as well as with 
ajax=False/ajax_trap=True), and it worked fine for me (though I did have to 
set auth.settings.login_next=URL('default','login2') -- otherwise, the 
component redirects to the index page, which displays the entire index page 
in the component div). Note, I don't think request.vars will show anything, 
because when you submit the login, it ends up redirecting, which generates a 
new request with empty request.vars.
 
Anthony

On Saturday, July 9, 2011 11:52:57 AM UTC-4, LightOfMooN wrote:

> ajax=True doesn't work too 
>
> I make it clear: 
> layout.html 
> {{=LOAD('default','login2',vars=request.vars, ajax=True)}} 
>
> default/login.html: 
> <div id="log_menu"> 
> {{=BEAUTIFY(request.vars)}} 
> {{if not auth.user:}} 
>     {{=form}} 
> {{else:}} 
>     <a href="{{=URL('default','user',args='logout')}}">logout</a> 
> {{pass}} 
> </div> 
>
> default.py: 
> def login2(): 
>     form=auth.login() 
>     return dict(form=form) 
>
> And it doesn't work with LOAD()    (doesn't matter ajax=False/True, 
> ajax_trap=False/True, I tried all) 
> Even if I click on submit, there are no vars from form.hidden_fields() 
> displayed. 
>
> On 9 июл, 20:47, Anthony <[email protected]> wrote: 
> > Not sure what the problem is. Is your login view login.html or 
> login.load? 
> > If the latter, your LOAD call should include 'login.load' (otherwise it 
> will 
> > default to 'load.html'). 
> > 
> > You might also consider using the form.custom elements to build your form 
>
> > rather than doing everything manually, as described here:
> http://web2py.com/book/default/chapter/07#Custom-forms. For example, 
> > form.custom.end will do the same thing as form.hidden_fields(), but will 
> > also add the closing </form> tag. 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Saturday, July 9, 2011 9:52:17 AM UTC-4, LightOfMooN wrote: 
> > > So, I changed LOAD to {{=LOAD('default','login', vars=request.vars, 
> > > ajax_trap=True, ajax=False)[0][0]}} 
> > > but it stays not to log in. 
> > > I add {{=BEAUTIFY(request.vars)}} in the default/login.html 
> > > When I click on submit, I see, that vars contains just password, 
> > > remember and username. 
> > > There are no vars from {{=form.hidden_fields()}} 
> > 
> > > On 9 июл, 19:29, Anthony <[email protected]> wrote: 
> > > > Try adding ajax_trap=True to your LOAD call. Without that, your form 
> will 
> > > be 
> > > > posted to the action of the parent page, which is not prepared to 
> process 
> > 
> > > > the login submission. ajax_trap=True will post the form submission 
> back 
> > > to 
> > > > the login() action. Or you can just use ajax=True for the login 
> > > component. 
> > 
> > > > Anthony 
> > 
> > > > On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote: 
> > > > > Hello. 
> > > > > I'm trying to make a login viewlet. 
> > 
> > > > > So, I have function in controller "default": 
> > > > > def login(): 
> > > > >     return dict(form=auth.login()) 
> > 
> > > > > And view: 
> > > > > <div id="log_menu"> 
> > > > > {{if not auth.user:}} 
> > > > >     <form action="" enctype="multipart/form-data" method="POST"> 
> > > > >     <div> 
> > > > >         Login<input name="username" type="text" value="" /> 
> > > > >     </div> 
> > > > >     <div> 
> > > > >         Password<input name="password" type="password" value="" /> 
> > > > >     </div> 
> > > > >     <div> 
> > > > >         <input name="remember" type="checkbox" value="on" 
> > > > > checked="checked">remember me 
> > > > >     </div> 
> > > > >     {{=form.hidden_fields()}} 
> > > > >     <div> 
> > > > >         <input class="formbutton" type="submit" value="login"> 
> > > > >     </div> 
> > > > >     </form> 
> > > > > {{else:}} 
> > > > >     <a href="{{=URL('default','user',args='logout')}}">logout</a> 
> > > > > {{pass}} 
> > > > > </div> 
> > 
> > > > > By url /default/login it works fine, but when I include it in 
> > > > > layout.html with 
> > > > > {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}} 
> > > > > it doesn't log user in. 
> > 
> > > > > How to make it works? thx

Reply via email to