[html-formfu] checkbox strangeness

Geoffrey D. Bennett g at netcraft.com.au
Mon Sep 15 15:07:59 BST 2008


Hi Ronald,

On Mon, Sep 15, 2008 at 09:31:57AM -0400, Ronald J Kimball wrote:
[...]
> It is common to have a group of checkboxes that share the same name, 
> each with a different value.  For example:
> 
> <input type="checkbox" name="interest" value="books">
> <input type="checkbox" name="interest" value="movies">
> <input type="checkbox" name="interest" value="cooking">
> <input type="checkbox" name="interest" value="sports">
> 
> If the checkboxes for books and cooking are checked, then the HTTP 
> request will include &interest=books&interest=cooking.

Ah, I see!  (I've always used different names when needing to do that
sort of thing).

> HTML::FormFu handles this correctly.

For a single form submission, maybe, but not for setting the "checked"
attribute correctly in displayed forms.  I just tried the form you
suggested above, and it only displays the checkboxes correctly if
there is no more than one checkbox selected (if more than one was
selected, they all end up unchecked).

The code in prepare_attrs() has expressions like '$value eq $original'
and '$default eq $original' which (unless I'm missing something else
again :-), don't allow for the possibility of more than one checkbox
being selected.

I'll have to rethink my proposal :-).  Thanks for your example.

Regards,
-- 
Geoffrey D. Bennett, RHCE, RHCX               mailto:g at netcraft.com.au
Senior Systems Engineer                          sip:g at netcraft.com.au
NetCraft Australia Pty Ltd        http://www.netcraft.com.au/geoffrey/



More information about the HTML-FormFu mailing list