[Zope] creating a data edit form

Tom P. Allred tom at allreddata.com
Mon Nov 10 09:19:25 EST 2003


Hi,

(It is not my intent to cross post but I sent this to the Formulator list
yesterday and still haven't seen it show up.)

I'm pretty new to Zope so please speak slowly and use small words. :o)
Several months ago I started a small learning project in Zope using
Formulator.  I got to the point of successfully creating data input forms,
storing the entered data in ZODB objects, cataloging the objects, and using
the catalog to retrieve and display data from an object.  Life intruded and
forced me to lay the project aside for a couple months but now I'm ready to
pick it back up.  I'm hoping someone can help kickstart me into the next
step which is providing a data edit form to let the user change previously
stored data.

Currently, to show previously saved data, I give the user a drop-down box
with all the record keys, let them select a key and click Submit, then use a
Python script to query the catalog and print/return the selected fields
(property values) to a display page.  What I'd like to do is return the
selected fields into the input form so the user can edit them.

Here is the ZPT code (taken from a forgotten example) used to display the
original input form.

<form name="dataform" method="post" action="formresult.zpt">

<!-- This starts the table that displays all fields on the form --->
<table tal:define="form here/dataform" align=left>

  <!-- Loop through the Formulator field ids to get the form fields --->
  <tr tal:repeat="itemz here/dataform/get_field_ids">
  <!-- Using span to define a block definition to hold a form field
object --->
  <span tal:define="fieldobj python:form.get_field(id=itemz)">
   <th align="left">
    <font size=4>
     <font face="verdana">
      <!-- Get/Display the title property of the current input field --->
      <b tal:content="fieldobj/title">Field Display Label</b>
      <b>:</b>
     </font>
    </font>
   </th>
   <td>
    <!-- Use Formulator render command to create the field data input
box --->
    <input type="text" name="itemz"
        tal:replace="structure python:fieldobj.render()">
   </td>
 </span>
 </tr>

 <!-- Tack on a Submit button and we are done --->
 <tr cols="*,350,*">
   <td>&nbsp;</td>
   <td align=left><input type="submit" value="  Submit  "></td>
   <td>&nbsp;</td>
 </tr>
</table><br>

</form>

Could someone please explain how to get the fields retrieved by my Python
script into the form so the user can change them?

Thanks,
Tom P. Allred, MCSE, RHCE, CCNA
Allred Data Consulting, Inc.
888-381-0611
www.AllredData.com
Tom at AllredData.com





More information about the Zope mailing list