Re: htmlfill question

Chris Lambacher <[email protected]> Sun, 5 Feb 2012 10:42:38 -0500
Newsgroups gmane.comp.python.formencode
Message-ID <CAAXXHgJ-73v+o4kkLKD-MO8yJKy_68Zx9+WdODm8RWc22ZROkg@mail.gmail.com>
--===============6840290371621440738==
Content-Type: multipart/alternative; boundary=f46d043743bf45088e04b8396560

--f46d043743bf45088e04b8396560
Content-Type: text/plain; charset=UTF-8

You should be able to use the formatter attribute to specify a custom
formatter:
http://www.formencode.org/en/latest/htmlfill.html#errors:
<form:error name="field_name" format="formatter">

You will also need to provide the error_formatters argument to renderer if
the formatter you want to use is not one of the default ones:
http://www.formencode.org/en/latest/modules/htmlfill.html#formencode.htmlfill.render

-Chris

On Sat, Feb 4, 2012 at 3:11 PM, Jonathan Vanasco <[email protected]> wrote:

>
> i'm a little confused by htmlfill's behavior on this.
>
> Given a form like 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" />
>
> and a call to htmlfill with this:
>    formencode.htmlfill.render(\
>            form_content,
>            defaults=defaults,
>            errors=errors,
>            auto_error_formatter=custom_formatter
>    )
>
> My output is essentially this:
>        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
> FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/formencode-discuss
>



-- 
Christopher Lambacher
[email protected]

--f46d043743bf45088e04b8396560
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

You should be able to use the formatter attribute to specify a custom forma=
tter:<div><span class=3D"pre" style=3D"color:rgb(68,68,68);font-family:Cons=
olas,&#39;Deja Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,monospa=
ce;font-size:15px;line-height:22px;text-align:left;background-color:rgb(242=
,242,242)"><a href=3D"http://www.formencode.org/en/latest/htmlfill.html#err=
ors">http://www.formencode.org/en/latest/htmlfill.html#errors</a>:</span></=
div>
<div><span class=3D"pre" style=3D"color:rgb(68,68,68);font-family:Consolas,=
&#39;Deja Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,monospace;fo=
nt-size:15px;line-height:22px;text-align:left;background-color:rgb(242,242,=
242)">&lt;form:error</span><span style=3D"color:rgb(68,68,68);font-family:C=
onsolas,&#39;Deja Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,mono=
space;font-size:15px;line-height:22px;text-align:left;background-color:rgb(=
242,242,242)">=C2=A0</span><span class=3D"pre" style=3D"color:rgb(68,68,68)=
;font-family:Consolas,&#39;Deja Vu Sans Mono&#39;,&#39;Bitstream Vera Sans =
Mono&#39;,monospace;font-size:15px;line-height:22px;text-align:left;backgro=
und-color:rgb(242,242,242)">name=3D&quot;field_name&quot;</span><span style=
=3D"color:rgb(68,68,68);font-family:Consolas,&#39;Deja Vu Sans Mono&#39;,&#=
39;Bitstream Vera Sans Mono&#39;,monospace;font-size:15px;line-height:22px;=
text-align:left;background-color:rgb(242,242,242)">=C2=A0</span><span class=
=3D"pre" style=3D"color:rgb(68,68,68);font-family:Consolas,&#39;Deja Vu San=
s Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,monospace;font-size:15px;lin=
e-height:22px;text-align:left;background-color:rgb(242,242,242)">format=3D&=
quot;formatter&quot;&gt;</span>=C2=A0</div>
<div><br></div><div>You will also need to provide the error_formatters argu=
ment to renderer if the formatter you want to use is not one of the default=
 ones:</div><div><a href=3D"http://www.formencode.org/en/latest/modules/htm=
lfill.html#formencode.htmlfill.render">http://www.formencode.org/en/latest/=
modules/htmlfill.html#formencode.htmlfill.render</a>
</div><div><br>-Chris</div><div><br><div class=3D"gmail_quote">On Sat, Feb =
4, 2012 at 3:11 PM, Jonathan Vanasco <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:[email protected]">[email protected]</a>&gt;</span> wrote:<br><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex">
<br>
i&#39;m a little confused by htmlfill&#39;s behavior on this.<br>
<br>
Given a form like this:<br>
 =C2=A0 =C2=A0 &lt;form:error name=3D&quot;Error_Main&quot;/&gt;<br>
 =C2=A0 =C2=A0 &lt;input id=3D&quot;login-email_address&quot; name=3D&quot;=
email_address&quot; placeholder=3D&quot;Email Address&quot; size=3D&quot;30=
&quot; type=3D&quot;text&quot; /&gt;<br>
 =C2=A0 =C2=A0 &lt;input id=3D&quot;login-password&quot; name=3D&quot;passw=
ord&quot; placeholder=3D&quot;Password&quot; size=3D&quot;30&quot; type=3D&=
quot;password&quot; /&gt;<br>
<br>
and a call to htmlfill with this:<br>
 =C2=A0 =C2=A0formencode.htmlfill.render(\<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0form_content,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0defaults=3Ddefaults,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0errors=3Derrors,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0auto_error_formatter=3Dcustom_for=
matter<br>
 =C2=A0 =C2=A0)<br>
<br>
My output is essentially this:<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0Error Main -- rendered with default formatter<b=
r>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0email_address -- rendered with custom formatter=
<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0password =C2=A0-- rendered with custom formatte=
r<br>
<br>
anyone have an idea to get the Error_Main section to render with the custom=
 formatter along with the other fields =C2=A0(aside from specifying a custo=
m renderer in the field and passing in a dict )?<br>
---------------------------------------------------------------------------=
---<br>
Try before you buy =3D See our experts in action!<br>
The most comprehensive online learning library for Microsoft developers<br>
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,<br=
>
Metro Style Apps, more. Free future releases when you subscribe now!<br>
<a href=3D"http://p.sf.net/sfu/learndevnow-dev2" target=3D"_blank">http://p=
.sf.net/sfu/learndevnow-dev2</a><br>
_______________________________________________<br>
FormEncode-discuss mailing list<br>
<a href=3D"mailto:FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org">FormEncode-disc=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/formencode-discuss"=
 target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/formencode-=
discuss</a><br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Christopher =
Lambacher<br><a href=3D"mailto:[email protected]">[email protected]=
et</a><br>
</div>

--f46d043743bf45088e04b8396560--


--===============6840290371621440738==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
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
--===============6840290371621440738==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/formencode-discuss

--===============6840290371621440738==--