Re: Mechanize and form->param()

"Paul Robbins" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Alex,
You are a lifesaver!! Have you talked to the people that host Form.pm to
have this change implemented?

~Paul

On 6/26/07, Alex Malek <[email protected]> wrote:
>
> > On 6/26/07, Alex Malek <[email protected]> wrote:
> > > The problem is in HTML::Form.pm
> > > I had the same issue and I wrote a fix for Form.pm
> > > I am attaching it.
> > >
> > > Let me know if it helps.
> > >
> > > ---Alex
> On 6/26/07, Paul Robbins <[email protected]> wrote:
> > What change did you make?
> >
> >
>
> The problem is the way Form.pm deals with multiple form select options
> with the same name.
>
> I altered Form.pm to handle that case.
>
> What you need to do is either replace Form.pm with the one I sent you
> or put it in a place in your path where it is used first.
>
> Below is the diff of the original Form.pm and and my new version.
>
>
> 153a155,156
> >  #select/option start code
> >  $attr->{START}="true";
> 156c159,164
> <  last if $tag eq "/select";
> ---
> >  if ($tag eq "/select") {
> >  #some select/option end code
> >  $attr->{END}="true";
> >  $f->push_input("option", $attr);
> >  last;
> >  }
> 172a181,183
> >  if ($attr->{START}) {
> >  delete $attr->{START}; #after first use remove
> >  }
> 188a200,202
> >  #some select/option end code
> >  $attr->{END}="true";
> >  $f->push_input("option", $attr);
> 823c837,851
> <  return $self->SUPER::add_to_form($form) unless $prev;
> ---
> >  # for option
> >  if ($type eq "option") {
> >  if ( defined $self->{START}) {
> >  return $self->SUPER::add_to_form($form);
> >  }
> >  my $i=1;
> >  while ($prev && (! defined $prev->{START}) ) {
> >  $prev = $form->find_input($self->{name}, $self->{type}, $i++);
> >  }
> >  if ( defined $prev->{START} && defined $self->{END}) {
> >  delete $prev->{START};
> >  return;
> >  }
> >  }
> >  return $self->SUPER::add_to_form($form) unless ($prev );
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.