Formulator - Database Edit form (solved)
RE: Setting up initial values on a formulator form from the contents of the DB. ( For a DB edit form ) I've found the solution by looking though the Formulator source. The following is a slight change to the index_html method in the Formulator HOWTO ( automatic method) . This form fills in the value of the fields with the current values of the DB. A ZSQL method is assumed to have been called prior to accessing this form by using direct traversal as explained by my last message. Hope this helps someone out, as I couldn't find the answer anywhere. Lee Marzke <lee.marzke@ametek.com> ==== <dtml-var standard_html_header> <dtml-var "form.header()"> <dtml-let me="this()"> <table border="0" width="50%"> <dtml-in "form.get_groups()"> <dtml-let group=sequence-item> <tr><th colspan="2" bgcolor="#F8F8F8"><dtml-var group></th></tr> <tr> <dtml-in "form.get_fields_in_group(group)"> <dtml-let field=sequence-item> <tr> <td><dtml-var "field.get_value('title')"></td> <td><dtml-if "_.getattr(me, field.id)"> <dtml-var "field.render(_.getattr(me, field.id))"> <dtml-else> <dtml-var "field.render()"> </dtml-if> </td> </tr> </dtml-let> </dtml-in> </tr> </dtml-let> </dtml-in> <tr> <td><input type="submit" value=" OK "></td> </tr> </table> </dtml-let> <dtml-var "form.footer()"> <dtml-var standard_html_footer> ============================================================ I'm following the recommendations on using Formulator forms and info in the Book of Zope and not having much luck translating the Add form ( which works great ) into an Edit form that must be filled in with existing values. My list method uses direct traversal to an zsql method, and I want to add an additional path to the Formulator form which will pre-fill in the values For instance, each item is listed with a link to the edit form like [ <a href="<dtml-var URL1>/user_by_id/&dtml-userid;/forms/userEdit/"> Edit </a> Where the user_by_id is a zsql method with direct traversal enabled. I added the "field.render(field[field.getId()], REQUEST) as suggested by some archived email message but I get the error. Error Type: AttributeError Error Value: __getitem__ When clicking the edit link. Any suggestions or examples on how to get formulator ( or forms in general ) to work with zsql would be appreciated.
participants (1)
-
Lee.Marzkeļ¼ ametek.com