[Zope] SQL Query -> DTML Form with populated values -> SQL update example??

Dieter Maurer dieter@handshake.de
Tue, 8 Aug 2000 21:02:51 +0200 (CEST)


Bill Broadley writes:
 > Does someone have an example (with DTML or similiar source) that
 > demonstrates the following:
 > 1.  A search field for record id, or a list with a clickable URL for each
 >     record (that is the result from a SQL select)
 > 2.  Allows updating of the record with a DTML form with values already
 >     populated
 > 3.  An SQL update based on the values from #2.
Where is your problem?

1. HTML form for record selection
....
<form action=populate_form>
Record_Id: <input name=record_id><br>
<input type=submit>
</form>
....

2. "populate_form" -- generates populated form
....
<dtml-let records=locate_by_record_id> <!-- "locate_by_record_id" is a 
                                            Z SQL Method with
					    arguement "record_id"
					    returning the corresponding
					    object -->
  <dtml-if "_.len(records)"> <!-- is there one? -->
    <dtml-with "records[0]"> <!-- take the first -->
      ... header ...
      <form action=update method=post>
        Field1: <input name=Field1 value="&dtml-Field1;"><br>
	.... do for all fields ....
	<input type=hidden name=record_id value="&dtml-record_id;">
	<input type=submit value="update">
      </form>
      ... footer ...
    </dtml-with>
  <dtml-else>
    ... error handling (no record for record_id) ...
  </dtml-if>
</dtml-let>

3. An SQL method with "record_id" and your fields as arguments
   and an SQL "update" as (query) template (as you did for
   "insert").



Dieter