The best way is just to give it a class

SQLFORM 
<http://127.0.0.1:8000/examples/global/vars/SQLFORM>.widgets.options.widget(field,
 value, _class="myclass" % field.image)

and then use JS (something like this):

jQuery(function(){
    jQuery('.myclass option').each(function() { 
        var image=jQuery(this).html()+'.png'
        jQuery(this).css('background-image','url('+image+')');
   });
});


On Monday, 28 April 2014 14:02:55 UTC-5, [email protected] wrote:
>
> I have a tables
>
> db.define_table('provider',
>                 Field 
> <http://127.0.0.1:8000/examples/global/vars/Field>('name'),
>                 Field 
> <http://127.0.0.1:8000/examples/global/vars/Field>('image', type='upload'),
>                 format='%(name)s',)
>
>
> db.define_table('payment',
>                 Field 
> <http://127.0.0.1:8000/examples/global/vars/Field>('provider', 'reference 
> provider'),
>
> ...
>
>
> how i can use "SQLFORM<http://127.0.0.1:8000/examples/global/vars/SQLFORM>
> .widgets.options.widget" 
>
> def index():
>     db.payment.provider.widget = lambda field, value: \
>         SQLFORM 
> <http://127.0.0.1:8000/examples/global/vars/SQLFORM>.widgets.options.widget(field,
>  value, _style='background-image:url(%s);' % field.image)
>
>
> to get something like this
>
> <select>
>   <option style="background-image:url(provider1.png);">Provider1</option>
>   <option style="background-image:url(provider2.png);">Provider2</option>
>   <option style="background-image:url(provider3.png);">Provider3</option>
> </select> 
>
> Thanks.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to