OK for subclassing object but there is already a way to change the size <script> $(document).ready(function(){$(#table_field).attr('size',80):}); </script> (I think this belongs to the view, not the widget, but if other people agree with you....)
and title db.table.field.label="My label" On May 28, 11:25 am, Iceberg <iceb...@21cn.com> wrote: > Hi Massimo, > > Please consider to change sqlhtml.py 's StringWidget to: > > class StringWidget(object): # I'll explain later > @staticmethod > def widget(field,value,**attributes): > .... > default_attributes=dict( > _type='text', > _id=id, > _class=field.type, > _name=field.name, > value=str(value), > requires=field.requires, > ) > default_attributes.update(attributes) > return INPUT(**default_attributes) > > This way, developers can customize the widget's _title or _size ... > etc. much easily, like this: > db.Field('addr','string',length=128, > widget=lambda f,v: StringWidget.widget( > f,v,_size=128,_title='Input your detail addr please')) > > Without the suggested improvement, currently I have to subclass a new > StringWidget to do that. > > Another minor suggestion is to change StringWidget's base class to > "object" (as I did in above example). This way the StringWidget will > become a "new-style" python class. Then when people need to subclass > it, they can use the python builtin super(...) function for more > convenience. > > These modifications are backward compatible. > > Same suggestions apply to TextWidget, BooleanWidget, OptionsWidget, > MultipleOptionsWidget, PasswordWidget, UploadWidget. > > Please consider it. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~----------~----~----~----~------~----~------~--~---