I ran into another issue, in case of multiple select=True the form won't 
submit, the moduleID field gives me a 'value not in database' error.

I adjusted my code, I moved the IS_EMPTY_OR(IS_IN_DB)) validator from the 
model:

Field('moduleID','reference module',ondelete='RESTRICT'),

 ... to the function:

if viewID==ONEMODULEVIEWID:
      
db.subscribe.moduleID.requires=IS_IN_DB(db,'module.id','%(name)s',multiple=False)
      db.subscribe.moduleID.widget=SQLFORM.widgets.radio.widget
if viewID==NMODULEVIEWID:
      
db.subscribe.moduleID.requires=IS_IN_DB(db,'module.id','%(name)s',multiple=True)
      db.subscribe.moduleID.widget=SQLFORM.widgets.checkboxes.widget

However, when I submitted the form it didn't validate because moduleID 
contained a list not an int or a str. I changed
the field definition to: 

Field('moduleID','list:reference module',ondelete='RESTRICT')

..which solved the problem, but I don't understand why, and how this is 
related to the IS_IN_DB() validators, which I not
only need to set multiple=True or False but also to label the radio buttons 
and checkboxes properly i.e. with a name not
an id.


Kind regards,

Annet

-- 

--- 
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/groups/opt_out.


Reply via email to