Nice!
On Nov 8, 12:47 pm, Thadeus Burgess <[email protected]> wrote:
> Thanks for the suggestions.
>
> I do like replacing the SQLFORM widgets because now it allows me to replace
> them with some of Freeze's widgets :)
>
> Now I can have input boxes that look themed along side my jquery ui css.
>
> jqueryui_content = "ui-widget ui-widget-content ui-corner-all"
> class UIStringWidget(StringWidget):
> @staticmethod
> def widget(field, value, **attributes):
> return StringWidget.widget(field, value, _class=jqueryui_content,
> **attributes)
>
> SQLFORM.widgets.string = UIStringWidget
>
> -Thadeus
>
> On Sun, Nov 8, 2009 at 11:49 AM, mdipierro <[email protected]> wrote:
>
> > why not?
>
> > On Nov 8, 10:35 am, Thadeus Burgess <[email protected]> wrote:
> > > What about just replacing SQLFORM.widgets with my own in db.py?
>
> > > -Thadeus
>
> > > On Sun, Nov 8, 2009 at 8:47 AM, mr.freeze <[email protected]> wrote:
>
> > > > Doh! He did say "every web2py form helper" though :)
>
> > > > On Nov 8, 8:45 am, mdipierro <[email protected]> wrote:
> > > > > Do not do this:
>
> > > > > gluon.sqlhtml.FormWidget._attributes = _attributes
>
> > > > > It would change the widget for all applications called concurrently.
>
> > > > > Instead do
>
> > > > > db.table.field.widget = lambda field: FormWidget(field,_attributes =
> > > > > _attributes)
>
> > > > > On Nov 8, 8:18 am, "mr.freeze" <[email protected]> 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 <[email protected]> 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 <
> > > > [email protected]>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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---