If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

I  thought that I understood something that I obviously don't !

It regards the usage of custom forms in order to customize the login table generated ( or serialized by web2py )

My objective is to place a different login form ( with different table settings ) in a 100px in height of a header ( similar to facebook ).

( this is an initiative to port a completely working and nice looking local working php & html app to web2py  - it was done with my own branded grid system of 20 columns ) !

PS. my equivalent layout.html is main_tpl.html

I have set up a test.html in the default view to try out different things with "custom  form  in conjunction with SQLFORM from the default.py controller and most have been successfull ". except the following :

This is what I have done and it is not working ! Please help !

in the controller ( default.py ) :

def test():
    return dict(form)

in the default view folder ( test.html ) :

{{extend 'main_tpl.html'}}
<h1>This is the test.html template</h1>

{{if form.errors:}}
  Your submitted form contains the following errors:
  {{for fieldname in form.errors:}}
    <li>{{=fieldname}} error: {{=form.errors[fieldname]}}</li>
<div class="col-12 last" id="toplogon">
          <table width="100%" border="0">
                  <td> {{=form.custom.label.email}}
                                <input name="email" type="text" class="string" id="auth_user_email" value="" />
                  <td> {{=form.custom.label.password}}
                            <input class="password" id="auth_user_password" name="password" type="password" class="field" value="" />
                  <td><br /><input name="submit" type="submit" class="nice tiny button radius" style="font-style:normal;font-size:14px;" value="{{=T('Log In &raquo')}}" /></td>
                  <td class="left">
                        <label><input class="checkbox" id="auth_user_remember" name="remember" type="checkbox" value="on" />{{=T('Remember me')}}</label>
                  <td><a href="{{=URL('default','/user/request_reset_password')}}">{{=T('Forgot password?')}}</a></td>


It is not working as expected and i cannot find the bug .. please help ... can someone please advise me what am I doing wrong .. what am I missing !??? ... thank you



Answers (2)

Comments (2)

  • Login to post

  • 0
    anthony 9 years ago


    That will not work. auth.login() itself returns a form (it also handles the processing of the form), so you cannot pass it to SQLFORM. Instead, just do:

    auth.settings.hideerror = True

    form = auth.login()

    Also, this:
    return dict(form)
    should be:

    return dict(form=form)



    replies (1)
    • don-clermont-10094 9 years ago

      thank you Anthony ... I did figuree that one out finally ...! ... I actually put it directly like " return dict(form = auth.login()) " and then it worked fine ! .. I got the settings like I wanted ! You are a real prince ! thanks again

  • 0
    don-clermont-10094 9 years ago

    It is still not working Anthony ...

    Any other ideas .. I even trimmed down the "test.html"  in order to have something showing up at least .. but nothing gives

    I get the following error msg in the ticket generated :

    <type 'exceptions.ValueError'> dictionary update sequence element #0 has length 4; 2 is required


    any ideas !!???

Related content

Hosting graciously provided by:
Python Anywhere