|
|
Choosing A Webhost: |
Re: radio inputs and disabled method: msg#00016lang.perl.modules.lwp
Joao Lopes <developer@xxxxxxxxxxxxxxxx> writes: > Hi, I modified Form.pm overriding method "disabled" in subclass > "HTML::Form::ListInput" (and form.t) and it seems to work as I would > expect. > Do you think attached patch is a good approach? Looks basically good. I modified into this one to make it do the right thing for select/option stuff as well. Thanks! To appear in LWP-5.805. Regards, Gisle Index: lib/HTML/Form.pm =================================================================== RCS file: /cvsroot/libwww-perl/lwp5/lib/HTML/Form.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -p -r1.53 -r1.54 --- lib/HTML/Form.pm 7 Dec 2005 09:33:34 -0000 1.53 +++ lib/HTML/Form.pm 7 Dec 2005 14:32:27 -0000 1.54 @@ -1,13 +1,13 @@ package HTML::Form; -# $Id: Form.pm,v 1.53 2005/12/07 09:33:34 gisle Exp $ +# $Id: Form.pm,v 1.54 2005/12/07 14:32:27 gisle Exp $ use strict; use URI; use Carp (); use vars qw($VERSION); -$VERSION = sprintf("%d.%03d", q$Revision: 1.53 $ =~ /(\d+)\.(\d+)/); +$VERSION = sprintf("%d.%03d", q$Revision: 1.54 $ =~ /(\d+)\.(\d+)/); my %form_tags = map {$_ => 1} qw(input textarea button select option); @@ -1035,13 +1035,13 @@ sub add_to_form if $type eq "checkbox"; if ($type eq "option" && exists $self->{multiple}) { - $self->{disabled} ||= $self->{option_disabled}; + $self->{disabled} ||= delete $self->{option_disabled}; return $self->SUPER::add_to_form($form); } die "Assert" if @{$self->{menu}} != 1; my $m = $self->{menu}[0]; - $m->{disabled}++ if $self->{option_disabled}; + $m->{disabled}++ if delete $self->{option_disabled}; my $prev = $form->find_input($self->{name}, $self->{type}); return $self->SUPER::add_to_form($form) unless $prev; @@ -1060,6 +1060,29 @@ sub fixup $self->{menu}[$self->{current}]{seen}++ if exists $self->{current}; } +sub disabled +{ + my $self = shift; + my $type = $self->type; + + my $old = $self->{disabled} || _menu_all_disabled(@{$self->{menu}}); + if (@_) { + my $v = shift; + $self->{disabled} = $v; + for (@{$self->{menu}}) { + $_->{disabled} = $v; + } + } + return $old; +} + +sub _menu_all_disabled { + for (@_) { + return 0 unless $_->{disabled}; + } + return 1; +} + sub value { my $self = shift; > > > For radio inputs, disabled method is always returning false (meaning > > "enabled"), even if all radio inputs are disabled. > > I think it should return something like: false if at least one radio > > with same name is not disabled...; true otherwise. > > > > Also when we try to enable the radio, and then modify the > > input->value, we don't succeed. > > I think it would be better if the method input->disabled(...) would > > enable/disable all radio buttons whithin the input.. > > > > I'm using libwww-perl-5.803... > > > > Sample code: > > > > use HTML::Form; > > > > my $f = HTML::Form->parse(<<EOT, "http://www.example.com"); > > <form> > > <input type=radio name=r0 value=1 disabled>one > > <input type=radio name=r0 value=2 disabled>two > > </form> > > EOT > > # here we see radio as not disabled > > print $f->dump; > > # try to enable it > > $f->find_input("r0")->disabled(0); > > # then we get the exception: The value '1' has been disabled for > > field 'r0' at > > $f->value("r0", 1); > > > > > > Has anyone had similar feeling/experience or am I missing something ?
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | libwww-perl-5.804, Gisle Aas |
|---|---|
| Next by Date: | Re: chunked transfer encoding and HTTP::Daemon, Gisle Aas |
| Previous by Thread: | libwww-perl-5.804, Gisle Aas |
| Next by Thread: | Re: chunked transfer encoding and HTTP::Daemon, Gisle Aas |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |