| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormHandler::Widget::Field::RadioGroup; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: radio group rendering widget |
|
3
|
|
|
|
|
|
|
$HTML::FormHandler::Widget::Field::RadioGroup::VERSION = '0.40068'; |
|
4
|
10
|
|
|
10
|
|
7707
|
use Moose::Role; |
|
|
10
|
|
|
|
|
28
|
|
|
|
10
|
|
|
|
|
108
|
|
|
5
|
10
|
|
|
10
|
|
52249
|
use namespace::autoclean; |
|
|
10
|
|
|
|
|
31
|
|
|
|
10
|
|
|
|
|
100
|
|
|
6
|
10
|
|
|
10
|
|
946
|
use HTML::FormHandler::Render::Util ('process_attrs'); |
|
|
10
|
|
|
|
|
29
|
|
|
|
10
|
|
|
|
|
106
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
0
|
36
|
sub type_attr { 'radio' } |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub render { |
|
12
|
14
|
|
|
14
|
0
|
50
|
my ( $self, $result ) = @_; |
|
13
|
14
|
|
66
|
|
|
300
|
$result ||= $self->result; |
|
14
|
14
|
50
|
|
|
|
51
|
die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result; |
|
15
|
14
|
|
|
|
|
66
|
my $output = $self->render_element( $result ); |
|
16
|
14
|
|
|
|
|
83
|
return $self->wrap_field( $result, $output ); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub render_element { |
|
20
|
14
|
|
|
14
|
0
|
49
|
my ( $self, $result ) = @_; |
|
21
|
14
|
|
33
|
|
|
50
|
$result ||= $self->result; |
|
22
|
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
35
|
my $output = ''; |
|
24
|
14
|
100
|
|
|
|
102
|
$output .= "<br />" if $self->get_tag('radio_br_after'); |
|
25
|
|
|
|
|
|
|
|
|
26
|
14
|
|
|
|
|
39
|
foreach my $option ( @{ $self->{options} } ) { |
|
|
14
|
|
|
|
|
62
|
|
|
27
|
36
|
100
|
|
|
|
134
|
if ( my $label = $option->{group} ) { |
|
28
|
4
|
50
|
|
|
|
143
|
$label = $self->_localize( $label ) if $self->localize_labels; |
|
29
|
4
|
|
100
|
|
|
27
|
my $attr = $option->{attributes} || {}; |
|
30
|
4
|
|
|
|
|
20
|
my $attr_str = process_attrs($attr); |
|
31
|
4
|
|
100
|
|
|
21
|
my $lattr = $option->{label_attributes} || {}; |
|
32
|
4
|
|
|
|
|
15
|
my $lattr_str= process_attrs($lattr); |
|
33
|
4
|
|
|
|
|
16
|
$output .= qq{\n<div$attr_str><label$lattr_str>$label</label>}; |
|
34
|
4
|
|
|
|
|
10
|
foreach my $group_opt ( @{ $option->{options} } ) { |
|
|
4
|
|
|
|
|
12
|
|
|
35
|
11
|
|
|
|
|
38
|
$output .= $self->render_option( $group_opt, $result ); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
4
|
|
|
|
|
17
|
$output .= qq{\n</div>}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
else { |
|
40
|
32
|
|
|
|
|
108
|
$output .= $self->render_option( $option, $result ); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
36
|
100
|
|
|
|
131
|
$output .= '<br />' if $self->get_tag('radio_br_after'); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
14
|
|
|
|
|
536
|
$self->reset_options_index; |
|
45
|
14
|
|
|
|
|
40
|
return $output; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub render_option { |
|
49
|
45
|
|
|
45
|
0
|
138
|
my ( $self, $option, $result ) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
45
|
|
66
|
|
|
134
|
$result ||= $result; |
|
52
|
45
|
|
|
|
|
144
|
my $rendered_widget = $self->render_radio( $result, $option ); |
|
53
|
45
|
|
|
|
|
162
|
my $output = $self->wrap_radio( $rendered_widget, $option->{label} ); |
|
54
|
45
|
|
|
|
|
1688
|
$self->inc_options_index; |
|
55
|
45
|
|
|
|
|
166
|
return $output; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub render_wrapped_option { |
|
59
|
1
|
|
|
1
|
0
|
4
|
my ( $self, $option, $result ) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
33
|
|
|
30
|
$result ||= $self->result; |
|
62
|
1
|
|
|
|
|
4
|
my $output = $self->render_option( $option, $result ); |
|
63
|
1
|
|
|
|
|
7
|
return $self->wrap_field( $result, $output ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub render_radio { |
|
67
|
45
|
|
|
45
|
0
|
102
|
my ( $self, $result, $option ) = @_; |
|
68
|
45
|
|
66
|
|
|
145
|
$result ||= $self->result; |
|
69
|
|
|
|
|
|
|
|
|
70
|
45
|
|
|
|
|
101
|
my $value = $option->{value}; |
|
71
|
45
|
|
|
|
|
1210
|
my $id = $self->id . "." . $self->options_index; |
|
72
|
45
|
|
|
|
|
1168
|
my $output = '<input type="radio" name="' |
|
73
|
|
|
|
|
|
|
. $self->html_name . qq{" id="$id" value="} |
|
74
|
|
|
|
|
|
|
. $self->html_filter($value) . '"'; |
|
75
|
45
|
100
|
|
|
|
202
|
$output .= ' checked="checked"' |
|
76
|
|
|
|
|
|
|
if $result->fif eq $value; |
|
77
|
45
|
|
|
|
|
246
|
$output .= process_attrs($option->{attributes}); |
|
78
|
45
|
|
|
|
|
140
|
$output .= ' />'; |
|
79
|
45
|
|
|
|
|
117
|
return $output; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub wrap_radio { |
|
83
|
45
|
|
|
45
|
0
|
123
|
my ( $self, $rendered_widget, $option_label ) = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
45
|
|
|
|
|
1217
|
my $id = $self->id . "." . $self->options_index; |
|
86
|
45
|
|
|
|
|
129
|
my $for = qq{ for="$id"}; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# use "simple" label attributes for inner label |
|
89
|
45
|
|
|
|
|
119
|
my @label_class = ('radio'); |
|
90
|
45
|
50
|
|
|
|
158
|
if ( $self->get_tag('inline') ) { |
|
91
|
0
|
|
|
|
|
0
|
my $class = 'inline'; |
|
92
|
0
|
0
|
|
|
|
0
|
$class = 'radio-inline' if $self->has_flag('is_b3'); |
|
93
|
0
|
|
|
|
|
0
|
push @label_class, $class; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
45
|
|
|
|
|
211
|
my $lattrs = process_attrs( { class => \@label_class } ); |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# return wrapped radio, either on left or right |
|
98
|
45
|
|
|
|
|
1676
|
my $label = $self->_localize($option_label); |
|
99
|
45
|
|
|
|
|
102
|
my $output = ''; |
|
100
|
45
|
50
|
|
|
|
160
|
if ( $self->get_tag('label_left') ) { |
|
101
|
0
|
|
|
|
|
0
|
$output = qq{<label$lattrs$for>\n$label\n$rendered_widget</label>}; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
else { |
|
104
|
45
|
|
|
|
|
170
|
$output = qq{<label$lattrs$for>$rendered_widget\n$label\n</label>}; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
45
|
100
|
|
|
|
144
|
if ( $self->get_tag('radio_element_wrapper') ) { |
|
107
|
12
|
|
|
|
|
40
|
$output = qq{<div class="radio">$output</div>}; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
45
|
|
|
|
|
138
|
return $output; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=pod |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=encoding UTF-8 |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
HTML::FormHandler::Widget::Field::RadioGroup - radio group rendering widget |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VERSION |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
version 0.40068 |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Renders a radio group (from a 'Select' field); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Tags: radio_br_after |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
See L<HTML::FormHandler::Field::Select> for documentation on |
|
135
|
|
|
|
|
|
|
select fields and options. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gerda Shank. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
146
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |