If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    mandriluy  13 years ago
    How can I adjust this to work with multiple ratings-style widgets on one form? I have a table with 6 integer fields, which I would all like to use this widget. However, when I do crud.create(db.staff_target), then I only get one star widget? I'm assuming that it's something to do with the _id="stars-cap" and _id="stars-wrapper" part of the rating_widget function? Example Snippet
    
    def rating_widget(f,v):
        from gluon.sqlhtml import OptionsWidget
        return DIV(SPAN(_id="stars-cap"), DIV(OptionsWidget.widget(f,v), _id="stars_wrapper"))
    
    db.define_table('my_table',
        Field('rating_procedural', 'integer', label="Procedures" ),
        Field('rating_control', 'integer', label="Game Control"),
    )
    
    db.staff_target.rating_procedural.requires=IS_IN_SET(range(0,6))
    db.staff_target.rating_procedural.widget=rating_widget
    db.staff_target.rating_control.requires=IS_IN_SET(range(0,6))
    db.staff_target.rating_control.widget=rating_widget
    
    
    I'm assuming that it's something to do with the rating_widget function returning a static id. Any suggestions on how to modify this would be appreciated...
    
    
    

Commented on:

This is how I got a star rating widget implemented on this site.

Hosting graciously provided by:
Python Anywhere