[Bese-devel] Patch for select fields

Marijn Haverbeke marijnh at gmail.com
Mon Jun 19 10:21:16 UTC 2006


Attached is a patch that makes some rather big changes to the select fields
in components/form.lisp, a small one to checkbox fields, and adds hidden
fields. Because it seems there is little animo for overhauling the
make-new-callback system, and the ucw_ajax branch uses hidden fields for
callbacks that are allways needed, I decided to just hack stuff with hidden
fields. Later, these hacks can be combined with the callback mechanisms in
ucw_ajax.

Changes to the select-field classes:
- They support the :multiple initarg. When this is true, the field will
allow multiple options to be selected, and its value and client-value will
be lists instead of single values.
- For alist, plist and hash fields, the interpretation of the data-sets has
changed. Basically, I reversed it, because this appears to make much more
sense to me, but this is debatable and if someone has a good reason why it
should be the other way I'd like to hear it. The way they work in my patch
is that they map lisp values to text labels. The select fields will show the
labels, and return the lisp values if you call value on them.
- Setting the value of mapping select fields now work like you'd expect it -
you give it a value of the kind that you would get if you call value,
instead of giving it a text label.
- Select fields no longer store their data-set. They transform it into a
data-map that maps client values, values, and text labels to each other, and
store that.
- There's a :traverse-func initarg for the select fields classes that allows
you to specify the way the data-set is mapped to value/label pairs. This is
used to implement plist, alist and hash selects, and can be used to do
fancier stuff.

There is now a class hidden-field. It works as you'd expect it to.

The checkbox-field class no longer resets itself every time it is rendered,
but instead uses the trick with the hidden input to call a function that
sets it to the right value after it is submitted.

I added a function next-anon-field-name that generates unique field names,
because the hidden-input trick requires some kind of name for the element
even when none is specified. Radio buttons also use this function now - they
used random strings before and a comment indicated that the person who put
that there didn't think this was a very good approach either.

Bye,
Marijn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060619/884905bc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: select-field-patch
Type: application/octet-stream
Size: 34117 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060619/884905bc/attachment.obj>


More information about the bese-devel mailing list