On Apr 2, 10:32 am, Jonathan Lundell <[email protected]> wrote:
> I think I've seen an answer to this one, but I can't find it.
>
> I've got a form with two Field's, both IS_IPV4(). The validation I'm after is 
> that one or both must be present; the only invalid case is both of them null.
>

.... sort of a situation as with checkboxes, multi-choice, but not-
none?   I see.

> How do I write that?

... If you are using one of the SQLFORM methods, you might consider
something like this:

    if form.accepts(request.vars, session=session, keepvalues=True,
dbio=False # this will allow you to add your combinatorial
validation):
        if at_least_one( request.vars.first, request.vars.second):
            session.flash = "Form Accepted!"
            # then follow the appropriate update or insert pattern
from http://www.web2py.com/book/default/section/7/2?search=dbio
            redirect(URL(r=request, c='default', f='index'))
        else
            response.flash = 'Form Error - must complete one of first or
second...'

    elif form.errors:
        response.flash = 'Form has errors...'

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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