I was looking at SQLFORM, and noticed that widgets do not actually get
passed any attributes... at all.

So why are they there? lol.

elif hasattr(field, 'widget') and field.widget:
                inp = field.widget(field, default)

Easily fixed to be

elif hasattr(field, 'widget') and field.widget:
                inp = field.widget(field, default, **attributes)

-Thadeus




On Tue, Nov 3, 2009 at 5:04 PM, Thadeus Burgess <thade...@thadeusb.com>wrote:

> Say I have a special value I want to pass to my widget. Like, date format.
> Which could change depending on the page.
>
> This is what I am trying to do.
>
> # pseudocode.
> def mywidget(f, v, **attr):
>     if attr.get("cancel", False):
>         return jQuery.Rating({cancel:true})
>
> But I can't seem to figure out where that **attr dictionary comes from, its
> not the SQLFORM, or the Field definitions?
>
> #db.define_table("table", Field("hi", widget=mywidget, cancel=True)
> #form = SQLFORM(db.table, cancel=True)
>
> So is there a proper way of doing this?
>
> -Thadeus
>
>
>
>
>
> On Tue, Nov 3, 2009 at 4:32 PM, mr.freeze <nat...@freezable.com> wrote:
>
>>
>> That's where the 'cheesy' part comes in.  This should really be done
>> as a class with options passed in the constructor. As it is, you need
>> to pass you attributes to the specific elements that will use them.
>> For example in the datepicker widget, I override the class so the
>> normal Calendar script doesn't affect it:
>>
>>  inp = SQLFORM.widgets.string.widget(f,v,_class="jqdate", **attr)
>>
>> On Nov 3, 4:28 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>> > Freeze,
>> >
>> > How would you pass variables to the **attr dict of the widgets?
>> >
>> > -Thadeus
>> >
>> > On Tue, Nov 3, 2009 at 4:06 PM, mr.freeze <nat...@freezable.com> wrote:
>> >
>> > > I have a cheesy autocomplete widget here. It's no match for the
>> > > facebook version but might help someone:
>> >
>> > >http://www.web2pyslices.com/main/slices/take_slice/24
>> >
>> > > On Nov 3, 11:24 am, Alex Fanjul <alex.fan...@gmail.com> wrote:
>> > > > I love this kind of widget!!! maybe your next challene would be the
>> so
>> > > > famous "facebook-autocomplete".
>> > > > Nowdays in facebook there is also a new feature where you can
>> appoint a
>> > > > "friend" writting "@friend" as twitter did it, but with
>> autocompleter...
>> >
>> > > > By the way Mr. Freeze, I think we should talk with someone who
>> proposed
>> > > > and was working on a wrapper framework por jquery widgets...
>> > > > I cant find the email.... She proposed us 3 options to choose for
>> > > > implementation...
>> >
>> > > > Alex F
>> >
>> > > > El 03/11/2009 7:06, mr.freeze escribió:
>> >
>> > > > > Nothing like a slice of web2py before bedtime :) I'm going widget
>> > > > > crazy! Here's an in-place edit widget that presents your text as a
>> > > > > SPAN until you double click then it changes into an input.
>> >
>> > > > >http://www.web2pyslices.com/main/slices/take_slice/23
>> >
>> > > > > On Nov 3, 12:01 am, mdipierro<mdipie...@cs.depaul.edu>  wrote:
>> >
>> > > > >> These slices taste excellent!
>> >
>> > > > >> On Nov 2, 11:56 pm, "mr.freeze"<nat...@freezable.com>  wrote:
>> >
>> > > > >>> Thanks, I updated it to specify adding to the model or
>> controller.
>> >
>> > > > >>> On Nov 2, 11:33 pm, mdipierro<mdipie...@cs.depaul.edu>  wrote:
>> >
>> > > > >>>> Thank you Mr Freeze.
>> >
>> > > > >>>> One comment. I do not think people should edit
>> web2py_ajax.html.
>> >
>> > > > >>>> response.files.append should go in plugin models or controller
>> of
>> > > the
>> > > > >>>> plugin; or the<scrip...>  should go directly in the views.
>> >
>> > > > >>>> Massimo
>> >
>> > > > >>>> On Nov 2, 10:48 pm, "mr.freeze"<nat...@freezable.com>  wrote:
>> >
>> > > > >>>>> Here are two ready to use widgets that employ the jQueryUI
>> slider
>> > > and
>> > > > >>>>> datepicker:
>> >
>> > > > >>>>> slider -http://www.web2pyslices.com/main/slices/take_slice/20
>> > > > >>>>> datepicker -
>> http://www.web2pyslices.com/main/slices/take_slice/22
>> >
>> > > > >>>>> Have fun!
>> >
>> > > > --
>> > > > Alejandro Fanjul Fdez.
>> > > > alex.fan...@gmail.comwww.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 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to