Hi Scott,
 
Please excuse the delay in replying... I'm not sure *how* easy it is relative to EmbPerl, but it's definitely possible in Spyce as well, and it's not very difficult. Do something like this. (Warning: I'm just typing this in, and it's not tested)
 
[[\
def default(value, def=''):
  if value==None: return def
  return value
]]
 
Then, you could write something like:
  <input name=foo value="[[=default(request.get1('foo', 'mydefault'))]]">
 
If you are using post data, then simply pass in request.post1('foo') above.
 
You could do something similar for selection form elements, perhaps using a function like:
[[
def defaultSelect(value, selection):
  if value==None: return ''
  if value==selection: return 'selected'
  return false
]]
 
Similarly, you could deal with checkboxes, and other form elements. Admittedly, it would be nice for this to be encoded as a module. I'll put it on the todo list. If you come up with a nice set of functions, which you think are convenient and represent the entire spectrum of HTML form capabilities, please think about making it into a module, and making it available to the community.
 
In general, I have been thinking about binding forms to data. I hope to (when I find the time) to also create a tag library that implements a similar functionality, and to perform this binding in a more general manner than I just described, which will also encapsulate form validation. Stay tuned...
 
All the best,
Rimon.
 
----- Original Message -----
From: "Scott Chapman" <scott_list@mischko.com>
To: <spyce-users@lists.sourceforge.net>
Sent: Saturday, February 08, 2003 10:39 PM
Subject: [Spyce-users] Pre-populating forms

Is there an easy way to pre-populate a form?

With EmbPerl, you can populate the %fdat{} hash (python = dictionary) and form
items are pre-populated with the relevant entry in %fdat. So if you have a
form input name="email" and you put an email address in $fdat{email} it will
show up as the value in the form in the user's web browser.  The user's data
coming from the form are found in %fdat{} also.  This is a VERY convenient
mechanism.

I've read the Spyce docs and I don't see that this can be done the same way
here.  Has anyone made a module to do this or did I miss something?

Failing all that, can this be added to Spyce?

Cordially,
Scott