Thanks!

Regards
Johann


On 10 October 2013 16:28, Vinicius Assef <[email protected]> wrote:

> You can use the "onvalidation" argument:
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation
>
> On Thu, Oct 10, 2013 at 10:51 AM, Johann Spies <[email protected]>
> wrote:
> > When using this form, how can I build a validator (or use some other way)
> > that ensure that the form will not be accepted if the combination of
> > survey_id and question_number  is not already in the table?
> >
> >     form = SQLFORM.factory(
> >                 Field('survey_id', db.survey, default = survey_id),
> >                 Field('question_number'),
> >                 Field('answer_type', 'integer',
> > requires=IS_IN_SET([(1,'Text'),
> >                                                      (2, 'Only one option
> > selected'),
> >                                                      (3, 'More than one
> > option selected')])))
> >
> > I have seen  the following answer by Anthony on Stackoverflow, but it
> breaks
> > in this case:
> >
> > db.questions.question_number.requires = IS_NOT_IN_DB(
> >       db(db.questions.question_number ==request.vars.question_number),
> > 'survey_id')
> >
> > The error:
> >
> >  File "/home/js/web2py/gluon/validators.py", line 653, in __call__
> >
> >     (tablename, fieldname) = str(self.field).split('.')
> >
> > ValueError: need more than 1 value to unpack
> >
> > Regards
> > Johann
> >
> >
> > --
> > Because experiencing your loyal love is better than life itself,
> > my lips will praise you.  (Psalm 63:3)
> >
> > --
> > 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 [email protected].
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to