[Zope] absent variables
Thomas B. Passin
tpassin@mitretek.org
Thu, 19 Apr 2001 10:36:38 -0400
You have two things to deal with.
1) You are using a checkbox for the "favorite" input element. When a
checkbox is not checked, it does not return a variable of that name in the
form.
2) You have more than one checkbox with the name "favorite". If more than
one are checked, the form will return a list containing all the values.
Furthermore, if only one is checked, the form will return a single string,
not a list. This would require further testing and handling. You can make
the form always return a list by changing the name of the input to
"favorite:list". You would still refer to the variable as "favorite".
Both possiblities will cause errors for your insert statement.
First, you need to decide whether you really want to allow more than one
"favorite" value. If you do, you need to figure out how they should be
represented in the database. Then you need to loop through the values.
If you decide you only want one value, you can change to using radio
buttons. One button could have the value '' (the empty string), and the
lable "No Favorite". This way, you would always get a single string in the
form data, although it might be an empty string. Your insert code would
work correctly.
Cheers,
Tom P
Miha" <Miha@instock.ru> asked -
>
> I meet problem, may be somebody can help me. I try to send results
> of filled form thought dtml-method (proxy of course), but user can
> don't fill some input values. When I submit form with unchecked
> checkbox (name favorite) I receive error:
> Error Type: Bad Request
> Error Value: ['favorite']
>
> How i can create default values for favorite?
> My SQL query for ZGadFlyDB:
> create TABLE REPORTS ( COUNTRY VARCHAR, REGION VARCHAR,
> TOWN VARCHAR, NAME VARCHAR,
> ADRESS VARCHAR, EMAIL VARCHAR,
> TEL VARCHAR, FAVORITE VARCHAR)
>