Subject: | Problem is Radio Buttons in HTML::DOM |
Hi,
I have found a problem with Radio Buttons using HTML::DOM. The problem
you cannot change the value of a NodeList::Radio using the ->value()
method. The value remains unchanged.
Attached is a patch that fixes the problem, for me at least. Doesn't seem
to break anything else.
Regards,
Martin
Subject: | radio_button_fix.patch |
--- Form.pm.orig 2011-01-20 11:59:39.494304600 +1000
+++ Form.pm 2011-01-20 12:02:33.111803357 +1000
@@ -430,16 +430,19 @@
$checked_elem = $btn, last;
}
- if (@_) { for (0..$self->length-1) {
- my $btn = $self->item($_);
- $_[0] eq $btn->attr('value') and
- $btn->disabled && croak(
- "The value '$_[0]' has been disabled for field '${\
- $self->name}'"
- ),
- $btn->checked(1),
- last;
- }}
+ if (@_) {
+ foreach my $element (@$self) {
+ if ($_[0] eq $element->attr('value')) {
+ if ($element->disabled) {
+ croak("The value '$_[0]' has been disabled for field '${$self->name}'");
+ }
+ $element->checked(1);
+ }
+ else {
+ $element->checked(0);
+ }
+ }
+ }
$checked_elem && $checked_elem->attr('value')
}