[Zope] check input
Dieter Maurer
dieter@handshake.de
Tue, 13 Feb 2001 20:28:22 +0100 (CET)
Olaf Zanger writes:
> > .... <input name="weight:float"> raises exception for empty field ....
> > What should happen, when the user does not provide the float?
> the ZSQL method has a dtml-if-statement. so it doesn't worry about a empty variable,
> but about a nonexisting.
"dtml-if" does not worry about a nonexisting variable, too.
Maybe, you need to give your "argument" a default value.
Otherwise, ZSQL may complain about a missing argument, before
the templates "dtml-if" has a chance.
> > * should the field be omitted?
> no, it should be empty or valid
>
> > Then try the ":ignore_empty" suffix.
> the zsql-method gives me a error message because variable does not exist
> where is that documented, i can't find it
":ignore_empty" tells ZPublisher to just discard empty variables.
If your ZSQL method does not provide a default value for this
variable (and it lists it as an argument, of cause),
then it will complain.
There is a HowTo on zope.org that explains the magic
ZPublisher form name suffixes.
> > * do you want a default value in this case?
> > Then try the ":default" suffix in an additional (hidden) form control
> > to provide this default!
> <input name:date:ignore_empty="min_date" value=""><input type="hidden"
> name:default="min_date" value="">
Help! What's that?
You do not append the suffixes to the HTML attribute names
but the the value of the NAME attribute.
Thus, this should look like:
<input type="hidden" name="min_date:date:default" value="1900/01/01">
<input name="min_date:date" value="">
> it doesn't work, what is wrong. i don't understand the conzept either.
Try to find the HowTo.
Dieter