Hello Thadeus, Mr.Freeze,
What is this for? to acommodate the same stylish widgets across application?
Could you give me an full simply code example please? For example, do I 
should use this method to obscure a little bit all input texts backgrounds?

Finally, what is the best correct solution? Thadeus at python class code 
or Mr.Freez at xml tag replacing?

Thanks in advance,
Alex F.

El 08/11/2009 15:45, mr.freeze escribió:
> Seems like you could do the same to DIV.xml (which most helpers derive
> from I believe):
>
> def xml(self):
>      (fa, co) = self._xml()
>      if 'class="' in fa:
>          fa = fa.replace('class="','class="myclass ')
>      if not self.tag:
>          return co
>      if self.tag[-1:] == '/':
>          return '<%s%s />' % (self.tag[:-1], fa)
>      return '<%s%s>%s</%s>' % (self.tag, fa, co, self.tag)
>
> import gluon.html
> gluon.html.DIV.xml = xml
>
> On Nov 8, 8:18 am, "mr.freeze"<nat...@freezable.com>  wrote:
>    
>> If you want to append a class to every widget, you can replace the
>> _attributes static method of sqlhtml.FormWidget. Try this in your
>> model:
>> ...
>> @staticmethod
>> def _attributes(field, widget_attributes, **attributes):
>>      attr = dict(
>>          _id = '%s_%s' % (field._tablename, field.name),
>>          _class = field.type,
>>          _name = field.name,
>>          requires = field.requires,
>>          )
>>      attr.update(widget_attributes)
>>      attr.update(attributes)
>>      attr.update(_class=attr['_class'] + ' myclass') #<-----NEW
>>      return attr
>>
>> import gluon.sqlhtml
>> gluon.sqlhtml.FormWidget._attributes = _attributes
>>
>> Or were you wanting to actually do it at the helper level?
>>
>> On Nov 8, 1:58 am, Thadeus Burgess<thade...@thadeusb.com>  wrote:
>>
>>      
>>> But I don't want the labels to have this class, just the actual form
>>> elements
>>>        
>>      
>>> -Thadeus
>>>        
>>      
>>> On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess<thade...@thadeusb.com>wrote:
>>>        
>>      
>>>> What would be the best way to automatically pass a certain class to every
>>>> web2py form helper? (INPUT, TEXTAREA, etc..)
>>>>          
>>      
>>>> -Thadeus
>>>>          
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web2py@googlegroups.com
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/web2py?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>
>    

-- 
Alejandro Fanjul Fdez.
alex.fan...@gmail.com
www.mhproject.org

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to