Hi Jonathan,
So I think the issue here is that the docs could be more clear:
auto_error_formatter is used to create the HTML that goes above the fields.
By default it wraps the error message in a span and adds a <br>.
In this text "is used to create the HTML that goes above the fields" is a
reference to the docs for the auto_insert_errors docs:
If auto_insert_errors is true (the default) then any errors for which
<form:error> tags canât be found will be put just above the associated
input field, or at the top of the form if no field can be found.
The docs there clearly indicate that the "auto_insert_errors" argument is
explicitly talking about errors that *don't* have a <form:error> tag. In
your case you *do* have a form error tag and if you want to override the
default formatter in that case then you need to set something in the
"error_formatters" argument. In other words, "auto_error_formatter" is not
a global catch all formatter for all errors, it is a catch all for errors
that don't have a "<form:error>" tag.
If you want to override the default formatter for "<form:error>" tags, pass
in error_formatters as {'default': my_formatter} and you will be off to the
races.
If you want to have a global default for your project, I recommend that you
write and use a wrapper function that provides the defaults you want while
passing through the parameters that you need to change regularly.
-Chris
Post by Jonathan VanascoThanks Chris.
I knew about being able to specify & pass custom formatters. I wanted to
avoid that, and rely on the auto error. I guess i wanted a clue on how to
patch formencode.
My issue is with the behavior I illustrated below, which I would consider a bug.
One would assume that if you pass in the "auto_error_formatter" argument,
it would be used for generating ALL errors. Instead it generates errors
only for html input type elements, and does not format the form:error
blocks.
<form:error name="field_name" format="formatter">
You will also need to provide the error_formatters argument to renderer if
http://www.formencode.org/en/latest/modules/htmlfill.html#formencode.htmlfill.render
-Chris
Post by Jonathan Vanascoi'm a little confused by htmlfill's behavior on this.
<form:error name="Error_Main"/>
<input id="login-email_address" name="email_address"
placeholder="Email Address" size="30" type="text" />
<input id="login-password" name="password" placeholder="Password"
size="30" type="password" />
formencode.htmlfill.render(\
form_content,
defaults=defaults,
errors=errors,
auto_error_formatter=custom_formatter
)
Error Main -- rendered with default formatter
email_address -- rendered with custom formatter
password -- rendered with custom formatter
anyone have an idea to get the Error_Main section to render with the
custom formatter along with the other fields (aside from specifying a
custom renderer in the field and passing in a dict )?
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
FormEncode-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/formencode-discuss
--
Christopher Lambacher
// Jonathan Vanasco
c. 646.729.6436 | 415.501.9815
w. http://findmeon.com/user/jvanasco
linkedin. http://linkedin.com/in/jonathanvanasco
blog. http://destructuring.net
--
Christopher Lambacher
***@kateandchris.net