[Zope] Using Form data values in ZSQL Method: I must be missing something here

Thomas B. Passin tpassin@mitretek.org
Tue, 19 Feb 2002 13:14:26 -0500


[Howard Hansen]

> I'm certain that I'm doing something very silly here, and I've learned
many
> new things about Zope and databases by researching this problem, but I
> haven't figured out how to make it work.
>
> All I want to do is create forms that allow me to insert or update records
> in a database.
>
> Here's the structure I've set up:
>
>     form: collects the form data, and when the user clicks submit, it
calls:
>     action_dtml_method: which calls:
>          zsql_method, which modifies the database
>          and tells the user what just happened
>
> When I hit Submit, I can easily list the values from the form inside the
> action_dtml_method, but zsql_method acts like it has no clue about the
form
> values.  It gives me the error:
>
>     Missing input variable, field_companyname
>
You have to do two things:

1) Declare the names of the parameters to plan to pass to the zsql method.
You do this in the Management Interface page where you define the zsql
method.

2) Use those parameters in your select statement, which is in the body of
the zsql method.

For example, if you have a form variable named "car_id", and you have
declared it as a property in the zsql form, then you could write

select * from cars where car=&dtml-car_id;

(Or you can use <dtml-var car_id> instead)

If this is not enough information, write again asking more specific
questions.

Cheers,

Tom P