In this group there are several discussions on this subject
(i.e.https://groups.google.com/d/msg/web2py/gLTthVDhqFM/dWldB9xGavgJ
)
Search for messages containing the word '_xml'
We are replacing the original form.custom.begin value with a new one within
which is the '_class' attribute
>From web2py code documentation in gluon/html.py (class DIV):
DIV class has a tag variable that is the tag name
FORM is a subclass of DIV and updates it
therefore, if form is an istance of FORM, form.tag will be = 'form'
_xml() is a helper for xml generation. Returns separately in a tuple:
- the component attributes
- the generated xml of the inner components
Component attributes start with an underscore ('_') and
do not have a False or None value. The underscore is removed.
A value of True is replaced with the attribute name.
Therefore form._xml()[0] returns the component attributes like '_action',
'_class'
from http://web2py.com/books/default/chapter/29/05?search=helper#XML
by using XML you can prevent escaping
so,
XML("<%s %s>" % (form.tag, form._xml()[0]))
returns
'<form action="" class="form-horizontal">'
Il giorno martedì 20 novembre 2012 23:37:17 UTC+1, Daniele ha scritto:
>
> Thanks that seems to have worked. This was totally undocumented (or if it
> was, it was in an obscure place because I looked quite hard for how to do
> this.) What does that XML("<%s %s>" % (form.tag, form._xml()[0])) line do
> exactly?
>
> I've now also edited my button to the style I wanted with
> form.custom.submit['_class'] = "btn btn-success"
>
> Thanks
>
> On Wednesday, August 15, 2012 6:51:12 AM UTC+1, shartha wrote:
>>
>> Hello,
>> Quick question:
>> Instead of {{=auth.login()}}, I am using the following to be able to
>> customize my login form. However the resulting form does not work and I
>> cannot login with the same username/password that enable me to login if I
>> had used {{=auth.login()}} -- I get the flash error: Invalid Login.
>>
>> Could someone please tell me what's possibly going wrong? Thanks!
>>
>> {{form=auth.login()}}
>> {{=form.custom.begin}}
>> Username:
>> {{=form.custom.widget.username}}
>> </br>
>> Password:
>> {{=form.custom.widget.password}}
>> {{=form.custom.submit}}
>> {{=form.custom.end}}
>>
>
--