>
> db.define_table('options',
>                 Field('question_id', db.questions),
>                 Field('option_number', requires = IS_NOT_EMPTY()),
>                 Field('option', requires = IS_NOT_EMPTY()),
>                 Field('dont_show_question', 'reference questions',
>                   requires = IS_IN_SET(lambda row: 
> questionlist(row.question_id))))
>

Is it the case that selecting a particular option can hide only a single 
other question, or do you want to allow multiple questions to be hidden? If 
the latter, you should either make dont_show_question a list:reference 
field (possibly rename to dont_show_questions or hide_questions) or create 
a linked table to store the questions to be hidden (I would go with 
list:reference).

As for generating the options, it appears you want to exclude the question 
associated with the current record. The problem is that you can't know that 
until the question number is chosen, and that is part of the same form. 
It's difficult to know what approach to take without knowing the workflow 
for creating a new question and its options. If a new question and its 
options are created together in a single form, then there's no need to 
worry about excluding the current question id from the dont_show_questions 
options, because the current question will not have been inserted into the 
database yet.

Finally, you probably don't need IS_IN_SET with a special function to 
generate options. Just use IS_IN_DB and specify a Set object as the first 
argument. You will need to know the current survey id at that point in 
order to limit the set to questions in the current survey (again, depends 
on your workflow, but presumably the survey id could be stored in the 
session).

Anthony

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to