nice point. :)

2013/5/10 Anthony <abasta...@gmail.com>

> Notice it is form.element(), not form.elements(). The first returns the
> first matching element -- the second returns a list (even if it contains
> only one match).
>
> Anthony
>
> On Friday, May 10, 2013 11:40:58 AM UTC-4, Ramos wrote:
>
>> *Note, form.element() returns the first matching element, so no need to
>> do form.elements(...)[0].*
>> *
>> *
>> This does not seem true
>>
>> if i remove [0] like this
>> a['_class'] = 'label label-warning'
>>
>> i get the error
>>
>>
>> TypeError: list indices must be integers, not str
>>
>>
>>
>> 2013/5/10 Anthony <abas...@gmail.com>
>>
>>>  Unless you are using formstyle='bootstrap', web2py does not add any
>>> class at all to <label> elements -- instead, the "w2p_fl' class is added to
>>> the label's parent element (which is a TD, DIV, or LI, depending on the
>>> formstyle). The 'bootstrap' formstyle adds a 'control-label' class directly
>>> to the label elements, but in that case, the code you have shown below
>>> would in fact completely replace the class, not merely append to it. If you
>>> want to access the parent element of the label, you can do:
>>>
>>> form.element('#trabalhador_**val_formacao__label').parent['**_class'] = 
>>> 'label
>>> label-warning'
>>>
>>> Note, form.element() returns the first matching element, so no need to
>>> do form.elements(...)[0].
>>>
>>> Anthony
>>>
>>>
>>> On Friday, May 10, 2013 5:42:58 AM UTC-4, Ramos wrote:
>>>>
>>>> hello this code
>>>>
>>>>     a=form.elements('#trabalhador_****val_formacao__label')
>>>>
>>>>     a[0]['_class'] = 'label label-warning'
>>>>
>>>>
>>>> only appends to the existing class in the label.
>>>>
>>>>
>>>> I want to replace existing label class with another one
>>>>
>>>> how do i do it?
>>>>
>>>>
>>>> Thank you
>>>> António
>>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to