[Html-widget] Radio button group

Matt Rosin mattr at telebody.net
Sat Sep 30 19:06:30 CEST 2006


I'm one of the OPs and starting to feel a bit responsible.. sorry I haven't
been able to participate more but I just tried rev 5042 from svn not cpan
yesterday. I got one error and then a lot of rendering/submission problems.

I am providing a copy of my app in case you are interested, for discussion
purposes:  http://telebody.net/projects/pubtest1/

The key files are as follows (*.latest-pretesting works, with pulldowns).

Please fill in your own dsn in Model/CatMgrDB.pm after making a database
(originally called tcp).  Sorry - I haven't figured out yet how to set the dsn
in the yml file. The widget code is at line 54 in make_category_widget().

There you will also see an attempt at a constraints hack to ensure unique name
and path in create and update, but I gave up using it for updating.  A best
HTML::Widget coding practices section about updating might be useful! If you
are interested I'm planning on an ajax-updated pulldown menu too if I have time.

Anyway, I undoubtedly have misunderstood parts of the discussion and the pods,
but it doesn't work for me. Possibly everything will turn out fine with
changes to the pod docs, if so I am willing to chip in there.

Click on element named "unused 1" after all the cities. Widget opens with a
checked checkbox. Hit submit without doing anything. I get:

Odd number of elements in hash assignment at
/usr/local/lib/perl5/site_perl/5.8.4/DBIx/Class/HTMLWidget.pm line 43.
[info] *** Request 7 (0.060/s) [15298] [Sat Sep 30 10:04:02 2006] ***
[debug] Body Parameters are:
| Parameter                           | Value                                |
| city                                | 1                                    |
| description                         | test                                 |
| disabled                            | 1                                    |
| flagged                             | 0                                    |
| name                                | unused 1                             |
| oldpath                             |                                      |
| parent                              | 0                                    |
| path                                | unused 1                             |
| section                             | 0                                    |
| submit                              | submit                               |

Still cannot uncheck a checked box. With a 0 in the database the widget
initializes with unchecked checkbox as I wish (though this is maybe a bug,
since I didn't tell it 0 means unchecked). But after checking the checkbox to
store a 1 in the database, thereafter cannot uncheck it (possibly because I
need retain_values or a new default value method).

I Would like to be able to make it logically similar to a radiogroup, so if
unchecked the widget will make it a 0 for No. I cannot tell if it is related
to the discussion of attributes or retain_default.. how to specify the default
value? What I would expect is a chainable checkbox method like
unchecked_value(0) to get a default value of 0 if unchecked. Or it could be
done similarly to the way you set values for all radio buttons at once, maybe
with a hash {unchecked => 0, checked => 1}. Maybe I am missing something
you've already got working. The way the word checked is used in Checkbox.pm
and RadioGroup.pm seem to be different. So I think the Checkbox pod needs some
more detail.

Updates the db correctly. The radio buttons update the db okay but the
checkbox still cannot uncheck a checked box, and also the radio buttons do not
render for me correctly yet (worse since I messed with the css file per the pod). 

Making changes as mentioned in the RadioGroup.pm pod (probably misunderstood)
I variously succeeded in getting the entire radiogroup to disappear, to appear
outside the widget and off the right side of the window, just getting labels
or radiobuttons themselves to appear, and getting a narrow fieldset sometimes
with a lone radio button overlapping the fieldset outline. Obviously I screwed
up and the docs are hard to understand (for someone who has not studied css
enough). Making .radio class inline also doesn't work.

While I'm at it, I found labels and comments to get mashed up against each
other. I solved it by making a lable_comment class (small, green) and
inserting a space in the string. However when I think about forms I have made
for professional jobs, they usually have a red asterisk if mandatory where the
label_comment is now, and any real (longish) comments show up to the right of
the control. Not to make your life hard or anything.. so maybe I misunderstand
the purpose of the comment, or is this correct?

Please take a look at the pod docs again especially for RadioGroup.pm. I
assume the right carat means to override label. There is a dangerous hyphen
that shows up in the pod (radiogroup_fieldset breaks a line after the letter
o). And the explanation of how to fix all the other label definitions is hard
to understand, for example should "label input {" become "label input,
.radiogroup_fieldset {" or (wrongly) "label, .radiogroup_fieldset input {". In
other words unless you are really used to using css it can be hard without a demo.

Well I am sorry to cause so much trouble but hope it is somewhat interesting.
Basically I just wanted to be able to make a form widget that acts like most
forms I've seen. I'm willing to help with documentation if necessary, and
think the pod should include actual examples of widgets with the css being
used so relative newbies can get going quickly.

Finally I really don't mean to start a flame war or insult anyone, but do
radiogroups really need to have a fieldset outline shown? (and is there a css
way to erase that black rectangle around it?).  It doesn't make sense visually
for a section of the form to be emphasized when it is not the most important
or mandatory part of it. (ducks) Since I am farther from the module code than
everyone I don't understand all the issues, but that lets me still think my
earlier mention of the </label> just being moved after the "Is a city?" string
and before the span begins (see my original post in Vol 5 Issue 11) instead of
it appearing after the span. Sorry if I am mentioning something that has
already been fixed, is necessary or violates the W3C standard. Perhaps this
answers your last question about using a fieldset?

Thank you very much and I will try to help more with testing if you need it.
By the way this is my first Catalyst app and usage of DBIx::Class, so please
let me know if you see any boneheaded mistakes. I hope it isn't too painful to
try. It's not quite as DRY as I hoped Catalyst would be (that is, it is but
there's too much typing still) yet. Well, for anyone interested enough to try
my code thank you and sorry for keeping you waiting for feedback.



More information about the Html-widget mailing list