htmlfill, errors and examples
michelts <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Hi guys,
I use formencode to validate my forms, I do the form presentation by
hand (I don't use any form generator), in my page I insert some tags
to be replaced by the error message (<form:error name="field">).
I had an idea, I want to be able to replace the tag by an example when
there is not error (the first time the form is loaded). Look:
# the raw code
Date: <input type="text" name="date"> <form:error name="date">
# the first time the form is loaded
Date: _____________ (ex: 2006/09/20)
# if there was an error
Date: 2006/02/31 the data is not valid
Is this a good idea? The validator class could have an attribute
called exampleMessage, It could have an attribute called showExample
too, that defaults to False, then I keep backward compatibility:
class DateValidator(FancyValidator):
showExample = False
def exampleMessage(self):
return datetime.datetime.now().strftime('%Y/%m/%d')
DateValidator(showExample=True).to_python('date')
Then htmlfill should check the need to show the example, and should
replace the error-wildcard by the example...
Before I get on the code I want to know opinions and suggestions, what
do you think about my idea?
Thanks for help!
--
Michel Thadeu Sabchuk
Curitiba - Brasil
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV