Hi Anthony,

  I tried that earlier also but that code didn't seem to work. I say so 
because my html page still has that login form on the left side of the 
navigation bar and looking at the source code, i see the following:
 <form  action="" enctype="multipart/form-data" method="post">
No class is added.
If I replace the custom form with a hard coded form with class name in the 
<form class= ...." then i am able to get the form in the right way.
So, it looks like somehow those statements to set class name are overridden 
by something else. I have these statements after the custom begin and 
custom end block in my view file so this is the last thing that is done to 
the form before it is rendered. 

I tried both your statements below and both of them didn't do anything. If 
you could also teach me how i can go and debug this situation, ( by looking 
at the form object in real time if possible to see how it gets modified 
during web2py execution on that page) it will help me in the long run... 

Thanks! 
-Bhaskar


On Wednesday, December 19, 2012 11:09:48 AM UTC-6, Anthony wrote:
>
> form['_class'] = 'myclass'
>
> or
>
> form.update(_class='myclass')
>
> A form is an HTML helper object, just like any other HTML helper, so the 
> usual rules apply: 
> http://web2py.com/books/default/chapter/29/05#HTML-helpers
>
> Anthony
>
> On Tuesday, December 18, 2012 11:33:32 PM UTC-5, Bhaskar Ramachandran 
> wrote:
>>
>> As listed in the "view" code below, i am trying to customize the form 
>> returned by auth.login(). Note that i have in my controller "return 
>> dict(form=auth.login()). Then in the view code pasted below i am 
>> customizing the login form.
>> It seems to work fine except that i am unable to assign a class name to 
>> this form. So my question is " How to set the class name for a form object 
>> ?. There are posts in the mailing list to specify class name for elements 
>> within the form object but i couldn't find one that explains how the class 
>> name for the form object itself can be assinged. 
>> Please let me know if my question needs more explanation. Thank you.
>>               {{
>>                     if not auth.is_logged_in() :
>>                               if not 'register' in auth.settings.
>> actions_disabled:
>>                                    form.add_button(T('Register'),URL(args
>> ='register'),_class='btn')
>>                                pass
>>                                    if not 'request_reset_password' inauth
>> .settings.actions_disabled:
>>                                      form.add_button(T('Lost Password'),
>> URL(args='request_reset_password'),_class='btn')
>>                             pass 
>>              }}
>>         
>>                     {{=form.custom.begin}}
>>                        <a href=
>> "/myscienceapp/default/register?_next=/default/index" style="margin-right: 
>> 10px">Sign Up</a>
>>                           <div class="input-append">
>>                              <input id="user_username" 
>> class="input-small" style="margin-right: 5px; border-radius: 5px 5px 5px 
>> 5px;" type="text" name="email" placeholder="Email"/>
>>                         <input id="user_password" class="input-small"style
>> ="margin-right: 2px; border-radius: 5px 5px 5px 5px;" type="password"name
>> ="password" placeholder="Password"/>
>>                               <input class="btn btn-primary" 
>> style="margin-right: 
>> 5px; margin-bottom: 0px;border-radius: 5px 5px 5px 5px;" size="5" type=
>> "submit" name="commit" value="Go!" />
>>                                <input id="user_remember_me" 
>> style="margin-right: 
>> 5px; margin-bottom: 16px;" type="checkbox" name="remember" value="1" />
>>                               <label class="string optional" 
>> style="margin-right: 
>> 10px;" for="user_remember_me">Remember me</label>
>>                           <a href="/users/sign_up" style="margin-right: 
>> 1px">Forgot?</a> 
>>                          </div>
>>                          {{=form.custom.end}}
>>        <!--Using the command below,i am trying to set the class name for 
>> the form.I was unable to do it both directly as well as using the parent() 
>> method.. -->
>>          {{form.element('div').parent['_class']='navbar-form pull-right 
>> form-inline'}}
>>         
>>                 {{pass}}
>>   
>>
>>

-- 



Reply via email to