App-Widget

 view release on metacpan or  search on metacpan

lib/App/Widget/RadioButtonSet.pm  view on Meta::CPAN

   $w = App::Widget::RadioButtonSet->new($config,$state,"gobutton", $config, $state);

=cut

######################################################################
# CONSTANTS
######################################################################

######################################################################
# ATTRIBUTES
######################################################################

# INPUTS FROM THE ENVIRONMENT

=head1 DESCRIPTION

This class is a <select> HTML element.

=cut

######################################################################
# CONSTRUCTOR
######################################################################

# uncomment this when I need to do more than just call SUPER::_init()
#sub _init {
#   my $self = shift;
#   $self->SUPER::_init(@_);
#}

######################################################################
# METHODS
######################################################################

######################################################################
# OUTPUT METHODS
######################################################################

sub html {
    my $self = shift;
    my ($context, $name, $curr_value, $values, $labels, $html_attribs);
    my ($nullable, $tabindex);
    my ($value, $v, @html, $label);

    $context  = $self->{context};
    $name     = $self->{name};

    $nullable = $self->get("nullable");
    $tabindex = $self->get("tabindex");

    ($values, $labels) = $self->values_labels();

    $html_attribs = $self->html_attribs();

    $tabindex = (defined $tabindex && $tabindex ne "") ? " tabindex=\"$tabindex\"" : "";

    @html = ();
    $curr_value = $self->get_value();
    for ($v = 0; $v <= $#$values; $v++) {
        $value = $values->[$v];
        $label = $self->html_escape($labels->{$value});
        push(@html,"  <input type=\"radio\" name=\"$name\" value=\"$value\"$tabindex".
            (($html_attribs) ? " $html_attribs" : "") .
            (($value eq $curr_value) ? " checked />" : " />") .
            $label .
            "<br>");
    }
    return join("",@html);
}

1;



( run in 0.551 second using v1.01-cache-2.11-cpan-437f7b0c052 )