cvsuser     02/04/19 07:35:39

  Added:       P5EEx/Blue/P5EEx/Blue/Widget/HTML RadioButtonSet.pm
  Log:
  new file
  
  Revision  Changes    Path
  1.1                  p5ee/P5EEx/Blue/P5EEx/Blue/Widget/HTML/RadioButtonSet.pm
  
  Index: RadioButtonSet.pm
  ===================================================================
  
  ######################################################################
  ## $Id: RadioButtonSet.pm,v 1.1 2002/04/19 14:35:39 spadkins Exp $
  ######################################################################
  
  package P5EEx::Blue::Widget::HTML::RadioButtonSet;
  $VERSION = do { my @r=(q$Revision: 1.1 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
  
  use P5EEx::Blue::Widget::HTML;
  @ISA = ( "P5EEx::Blue::Widget::HTML" );
  
  use strict;
  
  =head1 NAME
  
  P5EEx::Blue::Widget::HTML::RadioButtonSet - Set of HTML radio buttons
  
  =head1 SYNOPSIS
  
     use P5EEx::Blue::Widget::HTML::RadioButtonSet;
  
     $name = "gobutton";
     $config = { };
     $state = CGI->new({});
     $w = P5EEx::Blue::Widget::HTML::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);
      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();
  
      $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" .
              (($value eq $curr_value) ? " checked />" : " />") .
              $label .
              "\n");
      }
  
      return join("",@html);
  }
  
  1;
  
  
  
  


Reply via email to