QBit/WebInterface/Controller/Form/Field/select.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 4 SCAR 26.4
CC
4
Cov
0%
control_html
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.0
1 package QBit::WebInterface::Controller::Form::Field::select;
2 $QBit::WebInterface::Controller::Form::Field::select::VERSION = '0.033';
3 use qbit;
4  
5 use base qw(QBit::WebInterface::Controller::Form::Field);
6  
7 sub control_html {
8 my ($self) = @_;
9  
10 my $html = '<select';
11 $html .= $self->_class('span9');
12 foreach (qw(id name style)) {
13 $html .= " $_=\"" . html_encode($self->{$_}) . '"' if defined($self->{$_});
14 }
15 $html .= '>';
16  
17 $html .= '<option></option>' if $self->{'add_empty'};
18  
19 foreach my $option (@{$self->{'options'} || []}) {
20 $html .= '<option value="' . html_encode($option->{$self->{'items_key'}}) . '"';
21 $html .= ' selected="selected"'
22 if defined($self->{'value'})
23 && defined($option->{$self->{'items_key'}})
24 && $self->{'value'} eq $option->{$self->{'items_key'}};
25 $html .= '>' . html_encode($option->{$self->{'items_label'}}) . '</option>';
26 }
27  
28  
29 $html .= '</select>';
30  
31 $html .= $self->_html_error();
32  
33 return $html;
34 }
35  
36 TRUE;