line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Field::Display; |
2
|
|
|
|
|
|
|
# ABSTRACT: display only field |
3
|
|
|
|
|
|
|
$HTML::FormHandler::Field::Display::VERSION = '0.40067'; |
4
|
5
|
|
|
5
|
|
3358
|
use Moose; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
extends 'HTML::FormHandler::Field::NoValue'; |
6
|
5
|
|
|
5
|
|
22266
|
use namespace::autoclean; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
42
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'html' => ( is => 'rw', isa => 'Str', builder => 'build_html', lazy => 1 ); |
10
|
3
|
|
|
3
|
0
|
73
|
sub build_html {''} |
11
|
|
|
|
|
|
|
has 'set_html' => ( isa => 'Str', is => 'ro'); |
12
|
|
|
|
|
|
|
has '+do_label' => ( default => 0 ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'render_method' => ( |
15
|
|
|
|
|
|
|
traits => ['Code'], |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'CodeRef', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
predicate => 'does_render_method', |
20
|
|
|
|
|
|
|
handles => { 'render' => 'execute_method' }, |
21
|
|
|
|
|
|
|
builder => 'build_render_method', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub build_render_method { |
25
|
6
|
|
|
6
|
0
|
12
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
186
|
my $set_html = $self->set_html; |
28
|
6
|
|
66
|
|
|
32
|
$set_html ||= "html_" . HTML::FormHandler::Field::convert_full_name($self->full_name); |
29
|
2
|
|
|
2
|
|
4
|
return sub { my $self = shift; $self->form->$set_html($self); } |
|
2
|
|
|
|
|
52
|
|
30
|
6
|
100
|
66
|
|
|
141
|
if ( $self->form && $self->form->can($set_html) ); |
31
|
|
|
|
|
|
|
return sub { |
32
|
4
|
|
|
4
|
|
7
|
my $self = shift; |
33
|
4
|
|
|
|
|
139
|
return $self->html; |
34
|
4
|
|
|
|
|
150
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _result_from_object { |
38
|
1
|
|
|
1
|
|
2
|
my ( $self, $result, $value ) = @_; |
39
|
1
|
|
|
|
|
27
|
$self->_set_result($result); |
40
|
1
|
|
|
|
|
30
|
$self->value($value); |
41
|
1
|
|
|
|
|
34
|
$result->_set_field_def($self); |
42
|
1
|
|
|
|
|
3
|
return $result; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
46
|
5
|
|
|
5
|
|
1330
|
use namespace::autoclean; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
18
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=encoding UTF-8 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
HTML::FormHandler::Field::Display - display only field |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 0.40067 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This class can be used for fields that are display only. It will |
66
|
|
|
|
|
|
|
render the value returned by a form's 'html_<field_name>' method, |
67
|
|
|
|
|
|
|
or the field's 'html' attribute. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has_field 'explanation' => ( type => 'Display', |
70
|
|
|
|
|
|
|
html => '<p>This is an explanation...</p>' ); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
or in a form: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has_field 'explanation' => ( type => 'Display' ); |
75
|
|
|
|
|
|
|
sub html_explanation { |
76
|
|
|
|
|
|
|
my ( $self, $field ) = @_; |
77
|
|
|
|
|
|
|
if( $self->something ) { |
78
|
|
|
|
|
|
|
return '<p>This type of explanation...</p>'; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
|
|
|
|
|
|
return '<p>Another type of explanation...</p>'; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
#---- |
85
|
|
|
|
|
|
|
has_field 'username' => ( type => 'Display' ); |
86
|
|
|
|
|
|
|
sub html_username { |
87
|
|
|
|
|
|
|
my ( $self, $field ) = @_; |
88
|
|
|
|
|
|
|
return '<div><b>User: </b>' . $field->value . '</div>'; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
or set the name of the rendering method: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has_field 'explanation' => ( type => 'Display', set_html => 'my_explanation' ); |
94
|
|
|
|
|
|
|
sub my_explanation { |
95
|
|
|
|
|
|
|
.... |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
or provide a 'render_method': |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has_field 'my_button' => ( type => 'Display', render_method => \&render_my_button ); |
101
|
|
|
|
|
|
|
sub render_my_button { |
102
|
|
|
|
|
|
|
my $self = shift; |
103
|
|
|
|
|
|
|
.... |
104
|
|
|
|
|
|
|
return '...'; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Gerda Shank. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
116
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |