From edi at agharta.de Wed May 3 22:21:48 2006 From: edi at agharta.de (Edi Weitz) Date: Thu, 04 May 2006 00:21:48 +0200 Subject: [cl-who-devel] Pre-filled forms In-Reply-To: <290f54b70603290823m6516be60if5d9349e3bf2d6cf@mail.gmail.com> (Adam Thorsen's message of "Wed, 29 Mar 2006 08:23:43 -0800") References: <290f54b70603290823m6516be60if5d9349e3bf2d6cf@mail.gmail.com> Message-ID: Hi! Sorry, I'm obviously eons too late as I was pretty busy with other stuff in the last weeks. On Wed, 29 Mar 2006 08:23:43 -0800, "Adam Thorsen" wrote: > I'm using TBNL in a small web-app. A common need when developing > webapps is to display a form with fields pre-populated from the > database (i.e. email address, street address, etc.). > > I'm wondering if it's possible to do this with cl-who in some > generic way? I thought perhaps I could customize cl-who using the > convert-tag-to-string-list method. The function below overrides > default handling of (:input) tags to look for a :tuple attribute > with a value set to a hash containing the values from the database > needed to pre-fill the form the input element is part of. This > approach doesn't work, however, because convert-tag-to-string > serializes the string at compile time, and the data needs to be > retrieved from the database at run time. Any ideas? As the docs say (but probably don't explain good enough) you can return Lisp forms from your methods. Something like this (untested) should work: (defmethod convert-tag-to-string-list ((tag (eql :input)) attr-list body body-fn) (let ((name (cdr (assoc :name attr-list))) (tuple (cdr (assoc :tuple attr-list)))) (nconc (list* "")))) HTH, Edi.