3 CXGN::Page::Form::RadioList;
7 Implements a static (non-editable) list of radio buttons on a static form. For more information, see L<CXGN::Page::Form>.
16 use CXGN
::Page
::Form
::ElementI
;
18 package CXGN
::Page
::Form
::RadioList
;
20 use base qw
/ CXGN::Page::Form::ElementI /;
24 Usage: don't currently make use of the 'id' parameter, unlike other form fields
27 Args: a hashref with the following keys:
28 display_name (name of the field for display purposes)
29 field_name (name of the variable)
30 id_prefix (a string to be prepended to the choices to get radio-button element IDs)
31 choices (a listref of values for the buttons to be shown)
32 labels (a listref of labels for the buttons to be shown)
33 contents (the current value of the field; can be empty)
34 object (the object this field maps to)
35 getter (the getter function for this field in the object)
36 setter (the setter function for this field in the object)
46 my $self = $class->SUPER::new
(%params);
47 #store the parameters that aren't handled by our superclass
48 foreach my $param (qw(choices labels id_prefix))
50 my $set_func = "set_$param";
51 $self->$set_func($params{$param});
71 for(my $i = 0; $i < scalar($self->get_choice_array()); $i++)
73 if($self->get_contents() eq $self->get_choice($i))
75 $html .= "<li> » " . $self->get_label($i) . " « </li>";
79 $html .= "<li>" . $self->get_label($i) . "</li>";
82 return $html . "</ul>";
92 return $self->{id_prefix
};
104 return $self->{choices
}->[$i];
107 =head2 get_choice_array
109 Ret: array (not arrayref) of choices
116 return @
{$self->{choices
}};
128 return $self->{labels
}->[$i];
139 my ($self, $prefix) = @_;
140 $self->{id_prefix
} = $prefix;
145 Args: arrayref of choices
151 my ($self, $choices) = @_;
152 $self->{choices
} = $choices;
157 Args: arrayref of labels
163 my ($self, $labels) = @_;
164 $self->{labels
} = $labels;