[Html-widget] Radio button group

Matt Rosin mattr at telebody.net
Sat Sep 23 21:22:00 CEST 2006


I have a couple of questions (using HTML::Widget 1.09 on perl 5.8.4, linux).

I've had lots of trouble with checkboxes (empty ones not updated, as mentioned
in the ML) and radio groups (see below).  I resolved these by switching to
pulldown menus even for boolean items which leaves the questions up in the
air. This is a small app I built along the lines of the tutorial using
DBIx::Class and Mysql. Note these cases coincidentally are skipped by the

1. Radio buttons show up on two rows below their label's row, not on same line
as it. Can't figure out why, don't get containerizing and involvement of css.
Pasting into static html page comes out okay (on same line). So maybe a css issue?

2. You can select a radio button once with mouse, but the browser refuses to
let you click on the other radio spot to restore the value. 
   Firefox 1.07 (linux) maybe thinks the radio group is a label that can't be
changed, because the closing label tag appears on the last line, after the
span ends, and not before the span begins which is where I think it should be.
   This issue is fixed in static html by moving the label closing tag up to
before the span. In the catalyst app it resumes working if you just do not use
a label. Simply making two radio button elements did not seem to be a good
idea either. 
   Possibly FormElementContainer might work.. it works in the book demo but
failed in my app for some reason while studying the tutorial.

Please let me know if these things are both easily solved. If you can explain
the container stuff and how css works with it one more time that would also be
quite useful! Also would you recommend FormBuilder to solve these problems?
Thanks for all your effort.

Code in Controller object module:

my $ce = $w->element('RadioGroup','city');
$ce->label('Is a city?'); 	# label for whole group
$ce->values([0,1]);		# values of each radio
$ce->value([qw/0/]); 		# currently selected value (maybe unneeded)
$ce->labels([qw/No Yes/]);	# defaults to ucfirst of values, which is probably
arg3 in new.

Generated html (prettified):

<label id="category_form_city_label">Is a city?
  <label for="category_form_city_1" id="category_form_city_1_label">
    <input checked="checked" class="radio" id="category_form_city_1"
     name="city" type="radio" value="0" />
  <label for="category_form_city_2" id="category_form_city_2_label">
    <input class="radio" id="category_form_city_2"
     name="city" type="radio" value="1" />

Thank you very much!


Matt Rosin
Tokyo, Japan

More information about the Html-widget mailing list