Re: checkbox validation prob
"alain@free" <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
hi, yes it is a tos thing
I did different tries...
class DoIAgree(formencode.FancyValidator):
messages = {'my_empty': 'Do u agree or not?',
'missingValue': 'I Am Missing'}
def _to_python(self, value, state):
raise formencode.Invalid(self.message("my_empty", state), value,
state)
# TRY 0
tos = validators.NotEmpty(if_missing='' , messages={'empty': 'I am empty'})
# TRY 1
tos = formencode.All(validators.NotEmpty(if_missing=''), DoIAgree())
# TRY 1-1
tos = formencode.All(validators.NotEmpty(), DoIAgree())
# TRY 2
tos = DoIAgree()
# TRY 3
tos = validators.NotEmpty(messages={'empty': 'I am empty',
'missingValue': 'I Am Missing'})
nothing works, either the schema catches the missing cb and sends back a
"missing value" message
that i have no idea how to customize it
or i put a if_missing='' and nothing is called,
i dont know formencode very well..., what exactly do you call a schema
validation
i may be missing something :-)
Chris Cioffi wrote:
> On 4/12/07, alain@free <[email protected]> wrote:
>> hello
>> i have a checkbox prob
>> i would like to give a custom message when a cb is not checked
>> this fails:
>> tos = validators.NotEmpty(messages={'empty': 'I am empty'})
>> and the message i get is " Missing value"
>> from what i read this is expected as a default from Schema
>> when a field does not exists
>> when i try to give a default val as ''
>> tos = validators.NotEmpty(if_missing='' , messages={'empty': 'I am
>> empty'})
>> i dont get much succes and it is no more considered as empty
>> so what can i do to get my message for an unchecked cb
>> thanks
>
> I'm guessing that you've got something like a "I have read and agree
> to the TOS" and you want to require the checkbox to be checked before
> you complete the action.
>
> You probably need to check out the Schema validation instead of just
> validating on that one form field.
>
> Chris
-------------------------------------------------------------------------
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