I hate to answer my own post, but what if I did something in a customer 
Validator?  What if the error returned by my validator was something like 
SPAN("blah blah", _class="warning").  Presumably I could search the FORM 
using elements() finding my SPANs and then modify the enclosing DIVs to be 
class "warning" also.  I'd provide different CSS for the yellow background. 
 Just thinking out loud here.

On Wednesday, August 22, 2018 at 3:31:14 PM UTC-7, Joe Barnhart wrote:
>
> I'm looking to add "warnings" to forms using (/hijacking) as much of the 
> existing form "errors" mechanism as possible.  The idea is to provide a 
> second level check that gives advice rather than drop-dead errors.
>
> I would like it to operate like this:
>
> 1.  The form is submitted and checked for errors as usual. 
>
> 2.  After the error check another set of criteria, "warnings",  are 
> checked.  Where the errors are added as red elements below the fields, I'd 
> like these to be added in yellow to delineate the difference.
>
> 3.  The user gets a chance to fix the errors and warnings (as in standard 
> practice).
>
> 4.  If the error check passes but there are still warnings, the warnings 
> are displayed.
>
> 5.  Whatever the user submits after the "warnings only" check is accepted.
>
> I can figure out the two-phase form submit.  I was having a little 
> difficulty trying to imagine how to hijack the error message code that adds 
> the error wrapper.  Currently that's done in the xml method for the INPUT, 
> for example, and I don't see an easy way to extend that without subclassing 
> each of the controls and adding my stuff.  Even then, the Fields and such 
> would want to add the original INPUT and not my subclassed version, leading 
> to more fun and hilarity. 
>
> Any simple ideas from the web2py blackbelts?  I'm a brownbelt and can 
> probably implement it if you give me a hint.
>
> -- Joe
>
> P.S. An example of a warning would be if a user fills in his parent's last 
> name as his first name.  It's possible, but much more likely they just 
> switched the first name / last name fields.  (Happens a lot, for some 
> reason.)
>
>

-- 
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/d/optout.

Reply via email to