Discussion:
[albatross-users] Auto list bug/issue...
Michael C. Neel
2004-02-20 16:21:55 UTC
Permalink
I've come across a strang which is in 1.11+, maybe prior versions as
well but I didin't check them.

Normally, if you try to have several form fields defined with the same
name, you either need to use the "list" argument on the tags, or make
the list in the page object/module. This is very nice, because
albatross doesn't pull an perl like bs of thinking for you, and letting
some bug creep into production because it never caused a problem when
testing.

However, if you name several fields the same name, but they are
different types, you can get a field that will sometimes be a list,
sometime a string. To show this, here is a simple template that will
show the problem:

<html>
<body>
<al-form method="post">
<al-select name="selbox">
<al-option>Select1</al-option>
<al-option>Select2</al-option>
<al-option>Select3</al-option>
<al-option>Select4</al-option>
<al-option>Select5</al-option>
</al-select>
<br>
<al-input type="radio" name="selbox" value="Radio1">Radio1<br>
<al-input type="radio" name="selbox" value="Radio2">Radio2<br>
<br>
<al-input type="submit" name="submit" value="submit">
</al-form>
<br>
<b>selbox:</b> <al-value expr="locals().get('selbox')">
</body>
</html>

if you just submit, selbox is a string og the select box choice. If you
also select a radio, selbox is a list of the select box choice and the
radio choice. If you change either of the radio buttons to checkboxes
you will get the (excpected) traceback error that selbox is not defined
as a list.

Normally I would dig into the source to find out what's going on, but
since I'm pressed for time I thought I'd just send this now and if need
be I can dig deeper later.

Mike
Andrew McNamara
2007-03-14 00:35:51 UTC
Permalink
Post by Michael C. Neel
I've come across a strang which is in 1.11+, maybe prior versions as
well but I didin't check them.
Normally, if you try to have several form fields defined with the same
name, you either need to use the "list" argument on the tags, or make
the list in the page object/module. This is very nice, because
albatross doesn't pull an perl like bs of thinking for you, and letting
some bug creep into production because it never caused a problem when
testing.
However, if you name several fields the same name, but they are
different types, you can get a field that will sometimes be a list,
sometime a string. To show this, here is a simple template that will
Thanks for the report, Michael. I know it's been outstanding for a while!

The problem is due to inputs that can appear multiple times, but return
a single value (such as radio buttons and submit buttons). This simple
example exhibits the problem also (it should raise an exception on load,
but doesn't):

<al-form>
<al-input type="text" name="name">
<al-input type="radio" name="name">
</al-form>

I've checked a change in (r8871) that addresses this issue, and I hope
to be able to put out a new release later in the week.
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
Loading...