I have got the following model:

db.define_table('training',
    SQLField('trainingnummer', type='integer', length=6, notnull=True,
unique=True),
    SQLField('training', length=40, notnull=True, unique=True),
    migrate='training.table')


db.define_table('bedrijftraining',
    SQLField('bedrijf', db.bedrijf, notnull=True),
    SQLField('training', length=40, notnull=True),
    migrate='bedrijftraining.table')

db.bedrijftraining.bedrijf.requires=IS_IN_DB(db, 'bedrijf.id', '%
(bedrijfsnaam)s')
db.bedrijftraining.training.requires=IS_IN_DB(db,
'training.training','%(training)s')


In a controller I build a form using form_factory:

form=form_factory(SQLField('plaatsnaam',label='Type een
plaatsnaam',requires=IS_NOT_EMPTY()),
        SQLField('training', label='Selecteer een
activiteit',requires=IS_IN_DB(db,'training.training','%(training)s')))


Instead of the IS_IN_DB validator based on the training table I would
like the validator to be based on the bedrijftraining table, to
prevent visitors from entering a training that no bedrijf offers. I
tried this:

training=db().select(db.bedrijftraining.training,distinct=True)
    form=form_factory(SQLField('plaatsnaam',label='Type een
plaatsnaam',requires=IS_NOT_EMPTY()),
        SQLField('training', label='Selecteer een
activiteit',requires=IS_IN_DB(training,)))


Which results in the following error:

S'Traceback (most recent call last):\n  File "/Library/Python/2.5/site-
packages/web2py/gluon/restricted.py", line 62, in restricted\n    exec
ccode in environment\n  File "/Library/Python/2.5/site-packages/web2py/
applications/b2c/controllers/clubs.py", line 77, in <module>\n  File "/
Library/Python/2.5/site-packages/web2py/gluon/globals.py", line 55, in
<lambda>\n    self._caller=lambda f: f()\n  File "/Library/Python/2.5/
site-packages/web2py/applications/b2c/controllers/clubs.py", line 36,
in byactivity\n    SQLField(\'training\', label=\'Selecteer een
activiteit\',requires=IS_IN_DB(training)))\nTypeError: __init__()
takes at least 3 arguments (2 given)\n'


Does one of you how to solve this problem.


Best regards,

Annet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to