Hmm, works when I try it. Can you show the full controller code you have 
now?

On Monday, March 12, 2012 2:46:57 PM UTC-4, Sushant Taneja wrote:
>
> The rendered form is as:
>
> <form action="" enctype="multipart/form-data" method="post">
> ...
> </form>
>
> It has no attribute id.
>
> On Tuesday, March 13, 2012 12:05:02 AM UTC+5:30, Anthony wrote:
>>
>> What's not working? When you view the HTML code of the rendered page in 
>> the browser, is the id not there, or is it just that some client-side CSS 
>> or JS isn't working as expected? If the latter, the problem could be that 
>> you have put the form beginning and ending code inside the <table></table> 
>> tags rather than outside, where they belong. Should be:
>>
>> {{=login_form.custom.begin}} 
>> <table>
>> [snip]
>> </table>
>> {{=login_form.custom.end}}
>>
>> Anthony
>>
>> On Monday, March 12, 2012 2:07:20 PM UTC-4, Sushant Taneja wrote:
>>>
>>> Hi,
>>>
>>> I tried both but none seems to be working. Here's my view code:
>>>
>>>             <div id="formContainer">
>>>                 <table>
>>>                 {{=login_form.custom.begin}}
>>>                     <tr>
>>>                         <td 
>>> colspan='2'>{{=login_form.custom.widget.email}}</td>
>>>                     </tr>
>>>                     <tr>
>>>                         <td 
>>> colspan='2'>{{=login_form.custom.widget.password}}</td>
>>>                     </tr>
>>>                     <tr>
>>>                         <td><a href="#" id="flipToRecover" 
>>> class="flipLink">Forgot Password?</a></td>
>>>                         <td>{{=login_form.custom.submit}}</td>
>>>                     </tr>
>>>                 {{=login_form.custom.end}}
>>>                 </table>
>>>
>>> Please suggest.
>>>
>>> On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>>>>
>>>> That should work. Can you show the view code? Also, note you can just 
>>>> do:
>>>>
>>>> login_form['_id'] = 'login'
>>>>
>>>> Anthony
>>>>
>>>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>>>>
>>>>> I tried customizing the form. I have to set the id of the form element 
>>>>> to login.
>>>>> To achieve the above I used the following statement in controller:
>>>>>
>>>>> login_form = auth.login()
>>>>>
>>>>> # Configure form properties
>>>>> login_form.attributes['_id']='login'
>>>>>
>>>>> But it's not working. The generated form does not contain any id 
>>>>> attribute.
>>>>> Is there another way to do it ?
>>>>>
>>>>> Thanks,
>>>>> Sushant
>>>>>
>>>>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>>>>
>>>>>> Thanks for an explanatory answer.
>>>>>> I will try this out.
>>>>>>
>>>>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>>>>>
>>>>>>> def index():
>>>>>>>>
>>>>>>>>     login_form = auth.login()
>>>>>>>>     if login_form.process(session=None,formname='login').accepted:
>>>>>>>>         pass
>>>>>>>>     elif login_form.errors:
>>>>>>>>         response.write(request.vars)
>>>>>>>>     return dict()
>>>>>>>>
>>>>>>>> to display the form I have used the SQLForm in HTML technique as 
>>>>>>>> mentioned in the web2py book
>>>>>>>>
>>>>>>>> Whenever user enters the correct email and password. auth_event 
>>>>>>>> registers a login event with the description *User 1 Logged In*.
>>>>>>>> The next property redirects the URL to /user/profile but auth.user 
>>>>>>>> object is *None.*
>>>>>>>>
>>>>>>>
>>>>>>> auth.login() handles it's own form processing, and it uses the 
>>>>>>> session when calling form.accepts (which adds a hidden _formkey field 
>>>>>>> to 
>>>>>>> the form, which must be present upon form submission). In your code, 
>>>>>>> you do 
>>>>>>> not return the form object to the view, which means your view cannot 
>>>>>>> include the hidden _formkey field, which is therefore not submitted 
>>>>>>> with 
>>>>>>> the form. So, when the form is submitted, the form.accepts in 
>>>>>>> auth.login() 
>>>>>>> fails, which means the user object is never stored in session.auth.user 
>>>>>>> -- 
>>>>>>> hence, auth.user is None. The reason the login submission is successful 
>>>>>>> is 
>>>>>>> that your index() function then does its own processing of the login 
>>>>>>> form, 
>>>>>>> which is successful -- but your explicit call to login_form.process() 
>>>>>>> does 
>>>>>>> not do anything to set auth.user, so it is never set.
>>>>>>>
>>>>>>> In short, you should not be doing your own processing of the login 
>>>>>>> form -- let auth.login() handle that. And if you want to customize the 
>>>>>>> form 
>>>>>>> display in the view, you still have to return the form to the view so 
>>>>>>> you 
>>>>>>> can include the hidden _formkey and _formname fields in the form (you 
>>>>>>> can 
>>>>>>> use form.custom.end to do that).
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>
>>>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>>>>
>>>>> I tried customizing the form. I have to set the id of the form element 
>>>>> to login.
>>>>> To achieve the above I used the following statement in controller:
>>>>>
>>>>> login_form = auth.login()
>>>>>
>>>>> # Configure form properties
>>>>> login_form.attributes['_id']='login'
>>>>>
>>>>> But it's not working. The generated form does not contain any id 
>>>>> attribute.
>>>>> Is there another way to do it ?
>>>>>
>>>>> Thanks,
>>>>> Sushant
>>>>>
>>>>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>>>>
>>>>>> Thanks for an explanatory answer.
>>>>>> I will try this out.
>>>>>>
>>>>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>>>>>
>>>>>>> def index():
>>>>>>>>
>>>>>>>>     login_form = auth.login()
>>>>>>>>     if login_form.process(session=None,formname='login').accepted:
>>>>>>>>         pass
>>>>>>>>     elif login_form.errors:
>>>>>>>>         response.write(request.vars)
>>>>>>>>     return dict()
>>>>>>>>
>>>>>>>> to display the form I have used the SQLForm in HTML technique as 
>>>>>>>> mentioned in the web2py book
>>>>>>>>
>>>>>>>> Whenever user enters the correct email and password. auth_event 
>>>>>>>> registers a login event with the description *User 1 Logged In*.
>>>>>>>> The next property redirects the URL to /user/profile but auth.user 
>>>>>>>> object is *None.*
>>>>>>>>
>>>>>>>
>>>>>>> auth.login() handles it's own form processing, and it uses the 
>>>>>>> session when calling form.accepts (which adds a hidden _formkey field 
>>>>>>> to 
>>>>>>> the form, which must be present upon form submission). In your code, 
>>>>>>> you do 
>>>>>>> not return the form object to the view, which means your view cannot 
>>>>>>> include the hidden _formkey field, which is therefore not submitted 
>>>>>>> with 
>>>>>>> the form. So, when the form is submitted, the form.accepts in 
>>>>>>> auth.login() 
>>>>>>> fails, which means the user object is never stored in session.auth.user 
>>>>>>> -- 
>>>>>>> hence, auth.user is None. The reason the login submission is successful 
>>>>>>> is 
>>>>>>> that your index() function then does its own processing of the login 
>>>>>>> form, 
>>>>>>> which is successful -- but your explicit call to login_form.process() 
>>>>>>> does 
>>>>>>> not do anything to set auth.user, so it is never set.
>>>>>>>
>>>>>>> In short, you should not be doing your own processing of the login 
>>>>>>> form -- let auth.login() handle that. And if you want to customize the 
>>>>>>> form 
>>>>>>> display in the view, you still have to return the form to the view so 
>>>>>>> you 
>>>>>>> can include the hidden _formkey and _formname fields in the form (you 
>>>>>>> can 
>>>>>>> use form.custom.end to do that).
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>

Reply via email to