@@ -2057,6 +2057,8 @@ sub field {
20572057
20582058=head2 $mech->select($name, $new_or_additional_single_value)
20592059
2060+ =head2 $mech->select($name, $new_or_additional_single_value, $number)
2061+
20602062=head2 $mech->select($name, \%new_single_value_by_number)
20612063
20622064=head2 $mech->select($name, \@new_list_of_values)
@@ -2069,6 +2071,13 @@ specified.
20692071 # select 'foo'
20702072 $mech->select($name, 'foo');
20712073
2074+ The optional C<$number > parameter is used to distinguish between two fields
2075+ with the same name. The fields are numbered from 1. Note that this only works
2076+ for selecting simple values, not for selecting multiple values as once.
2077+
2078+ # select the second field with the name 'foo'
2079+ $mech->select($name, 'foo', 2);
2080+
20722081If the field is not C<< <select multiple> >> and the
20732082C<$value > is an array reference, only the B<first > value will be set. [Note:
20742083until version 1.05_03 the documentation claimed that only the last value would
@@ -2117,11 +2126,12 @@ false and calls C<< $self->warn() >> with an error message.
21172126=cut
21182127
21192128sub select {
2120- my ( $self , $name , $value ) = @_ ;
2129+ my ( $self , $name , $value , $number ) = @_ ;
2130+ $number ||= 1;
21212131
21222132 my $form = $self -> current_form();
21232133
2124- my $input = $form -> find_input($name );
2134+ my $input = $form -> find_input( $name , undef , $number );
21252135 if ( !$input ) {
21262136 $self -> warn (qq{ Input "$name " not found} );
21272137 return ;
@@ -2188,7 +2198,7 @@ sub select {
21882198 return 1;
21892199 }
21902200
2191- $form -> value ( $name => $value );
2201+ $form -> find_input ( $name , undef , $number ) -> value( $value );
21922202 return 1;
21932203}
21942204
0 commit comments