I cannot reproduce this error running the exact code you have below.
Anthony
On Sunday, December 18, 2011 5:16:48 AM UTC-5, Paolo Caruccio wrote:
>
> *Scenario*
>
> 1. #model db.py
> db.define_table('specializzazioni',
> Field('specializzazione',
> type='string',notnull=True,label=T('Specialization')),
> format='%(specializzazione)s',
> )
>
> db.define_table('t_valutazione_risorsa',
> Field('f_specializzazione',type='list:reference
> specializzazioni',notnull=True,label=T('Specialization')),
>
> Field('f_valutazione_qualifica',type='string',notnull=True,label=T('Rating')),
> )
> db.t_valutazione_risorsa.f_specializzazione.requires = [IS_IN_DB(db,
> db.specializzazioni.id, db.specializzazioni._format,
> multiple=True),IS_NOT_EMPTY()]
> db.t_valutazione_risorsa.f_specializzazione.widget =
> SQLFORM.widgets.multiple.widget
>
> 2. # controller default.py
> def test():
> form = SQLFORM(db.t_valutazione_risorsa)
>
> if form.accepts(request, session):
> response.flash = T('resource rating added')
>
> if isinstance(form,FORM):
> ms = form.element("select", _name='f_specializzazione')
> ms["_class"]="chosen"
> ms.parent["_class"]="multi"
>
> return dict(form=form)
>
> *Error traceback*
>
> Traceback (most recent call last):
> File "M:\UniServer\www\web2py_trunk\gluon\restricted.py", line 204, in
> restricted
> exec ccode in environment
> File
> "M:/UniServer/www/web2py_trunk/applications/test/controllers/default.py"
> <http://127.0.0.1:8000/admin/default/edit/test/controllers/default.py>, line
> 85, in <module>
> File "M:\UniServer\www\web2py_trunk\gluon\globals.py", line 172, in <lambda>
> self._caller = lambda f: f()
> File
> "M:/UniServer/www/web2py_trunk/applications/test/controllers/default.py"
> <http://127.0.0.1:8000/admin/default/edit/test/controllers/default.py>, line
> 81, in test
> ms.parent["_class"]="multi"
> TypeError: 'NoneType' object does not support item assignment
>
>
> Wondering why this happens?
>
> Thank you for your reply.
>