I am trying to create a short validator that limits the number of children that can be listed under one parent but I'm having a problem with the highlighted line because I cant use *parent.id *to specify the selected parent when the parent variable is referenced outside the validator function. I rightfully get: *<type 'exceptions.NameError'> global name 'parent' is not defined*
Anyone on ideas on how to work around this? def my_validator(form): * if db((db.children.id>0) & (db.children.parent==parent.id)).count() >=10:* form.errors.children_names=SPAN("The number of children has exceeded the required number") def registration(): * parent=db.parent(request.args(0, cast=int)) #referenced outside the validator function* db.children.parent.default=parent.id form=SQLFORM(db.children) if form.process(onvalidation=my_validator).accepted: response.flash=T('Client Registered') return locals() -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/c46b4101-7d5f-4df7-ab24-88d57772d3afn%40googlegroups.com.