<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package HTML::Form::Input;

use strict;

our $VERSION = '6.11';

# ABSTRACT: A generic HTML form input element for use with HTML::Form

sub new {
    my $class = shift;
    my $self  = bless {@_}, $class;
    $self;
}

sub add_to_form {
    my ( $self, $form ) = @_;
    push( @{ $form-&gt;{'inputs'} }, $self );
    $self;
}

sub strict {
    my $self = shift;
    my $old  = $self-&gt;{strict};
    if (@_) {
        $self-&gt;{strict} = shift;
    }
    $old;
}

sub fixup { }

sub type {
    shift-&gt;{type};
}

sub name {
    my $self = shift;
    my $old  = $self-&gt;{name};
    $self-&gt;{name} = shift if @_;
    $old;
}

sub id {
    my $self = shift;
    my $old  = $self-&gt;{id};
    $self-&gt;{id} = shift if @_;
    $old;
}

sub class {
    my $self = shift;
    my $old  = $self-&gt;{class};
    $self-&gt;{class} = shift if @_;
    $old;
}

sub selected {
    my ( $self, $sel ) = @_;
    return undef unless defined $sel;
    my $attr
        = $sel =~ s/^\^// ? "name"
        : $sel =~ s/^#//  ? "id"
        : $sel =~ s/^\.// ? "class"
        :                   "name";
    return 0 unless defined $self-&gt;{$attr};
    return $self-&gt;{$attr} eq $sel;
}

sub value {
    my $self = shift;
    my $old  = $self-&gt;{value};
    $self-&gt;{value} = shift if @_;
    $old;
}

sub autocomplete {
    my $self = shift;
    my $old  = $self-&gt;{autocomplete};
    $self-&gt;{autocomplete} = shift if @_;
    $old;
}

sub possible_values {
    return;
}

sub other_possible_values {
    return;
}

sub value_names {
    return;
}

sub readonly {
    my $self = shift;
    my $old  = $self-&gt;{readonly};
    $self-&gt;{readonly} = shift if @_;
    $old;
}

sub disabled {
    my $self = shift;
    my $old  = $self-&gt;{disabled};
    $self-&gt;{disabled} = shift if @_;
    $old;
}

sub form_name_value {
    my $self = shift;
    my $name = $self-&gt;{'name'};
    return unless defined $name;
    return if $self-&gt;disabled;
    my $value = $self-&gt;value;
    return unless defined $value;
    return ( $name =&gt; $value );
}

sub dump {
    my $self = shift;
    my $name = $self-&gt;name;
    $name = "&lt;NONAME&gt;" unless defined $name;
    my $value = $self-&gt;value;
    $value = "&lt;UNDEF&gt;" unless defined $value;
    my $dump = "$name=$value";

    my $type = $self-&gt;type;

    $type .= " disabled" if $self-&gt;disabled;
    $type .= " readonly" if $self-&gt;readonly;
    return sprintf "%-30s %s", $dump, "($type)" unless $self-&gt;{menu};

    my @menu;
    my $i = 0;
    for ( @{ $self-&gt;{menu} } ) {
        my $opt = $_-&gt;{value};
        $opt = "&lt;UNDEF&gt;" unless defined $opt;
        $opt .= "/$_-&gt;{name}"
            if defined $_-&gt;{name} &amp;&amp; length $_-&gt;{name} &amp;&amp; $_-&gt;{name} ne $opt;
        substr( $opt, 0, 0 ) = "-" if $_-&gt;{disabled};
        if ( exists $self-&gt;{current} &amp;&amp; $self-&gt;{current} == $i ) {
            substr( $opt, 0, 0 ) = "!" unless $_-&gt;{seen};
            substr( $opt, 0, 0 ) = "*";
        }
        else {
            substr( $opt, 0, 0 ) = ":" if $_-&gt;{seen};
        }
        push( @menu, $opt );
        $i++;
    }

    return sprintf "%-30s %-10s %s", $dump, "($type)",
        "[" . join( "|", @menu ) . "]";
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

HTML::Form::Input - A generic HTML form input element for use with HTML::Form

=head1 VERSION

version 6.11

=head1 AUTHOR

Gisle Aas &lt;gisle@activestate.com&gt;

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 1998 by Gisle Aas.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
</pre></body></html>