=item $form->method( $new_method )
This method is gets/sets the I<method> name used for the
C<HTTP::Request> generated. It is a string like "GET" or "POST".
=item $action = $form->action
=item $form->action( $new_action )
This method gets/sets the URI which we want to apply the request
I<method> to.
=item $enctype = $form->enctype
=item $form->enctype( $new_enctype )
This method gets/sets the encoding type for the form data. It is a
string like "application/x-www-form-urlencoded" or "multipart/form-data".
=cut
BEGIN {
# Set up some accesor
for (qw(method action enctype)) {
my $m = $_;
no strict 'refs';
*{$m} = sub {
my $self = shift;
my $old = $self->{$m};
$self->{$m} = shift if @_;
$old;
};
}
*uri = \&action; # alias
}
=item $value = $form->attr( $name )
=item $form->attr( $name, $new_value )
This method give access to the original HTML attributes of the <form> tag.
The $name should always be passed in lower case.
Example:
@f = HTML::Form->parse( $html, $foo );
@f = grep $_->attr("id") eq "foo", @f;
die "No form named 'foo' found" unless @f;
$foo = shift @f;
=cut
sub attr {
my $self = shift;
my $name = shift;
return undef unless defined $name;
my $old = $self->{attr}{$name};
$self->{attr}{$name} = shift if @_;
return $old;
}
=item $bool = $form->strict
=item $form->strict( $bool )
Gets/sets the strict attribute of a form. If the strict is turned on
the methods that change values of the form will croak if you try to
set illegal values or modify readonly fields. The default is not to be strict.
=cut
sub strict {
my $self = shift;
my $old = $self->{strict};
if (@_) {
$self->{strict} = shift;
for my $input (@{$self->{inputs}}) {
$input->strict($self->{strict});
}
}
return $old;
}
=item @inputs = $form->inputs
This method returns the list of inputs in the form. If called in
scalar context it returns the number of inputs contained in the form.
See L</INPUTS> for what methods are available for the input objects
returned.
=cut
sub inputs
{
my $self = shift;
@{$self->{'inputs'}};
}
=4= |