line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SparkX::Form::Field::Checkbox; |
2
|
|
|
|
|
|
|
our $VERSION = '0.2102'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: A Checkbox field for SparkX::Form |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
513
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
4736
|
use HTML::Tiny; |
|
1
|
|
|
|
|
1909
|
|
|
1
|
|
|
|
|
144
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Spark::Form::Field'; |
11
|
|
|
|
|
|
|
with 'Spark::Form::Field::Role::Printable::HTML', |
12
|
|
|
|
|
|
|
'Spark::Form::Field::Role::Printable::XHTML'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has '+value' => ( |
15
|
|
|
|
|
|
|
isa => 'Str', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub to_html { |
19
|
0
|
|
|
0
|
1
|
0
|
return shift->_render(HTML::Tiny->new(mode => 'html')); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub to_xhtml { |
23
|
2
|
|
|
2
|
1
|
815
|
return shift->_render(HTML::Tiny->new(mode => 'xml')); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _render { |
27
|
2
|
|
|
2
|
|
69
|
my ($self, $html) = @_; |
28
|
|
|
|
|
|
|
|
29
|
2
|
100
|
|
|
|
74
|
return $html->input({ |
30
|
|
|
|
|
|
|
type => 'checkbox', |
31
|
|
|
|
|
|
|
value => 1, |
32
|
|
|
|
|
|
|
($self->value ? (checked => 'checked') : ()), |
33
|
|
|
|
|
|
|
name => $self->name |
34
|
|
|
|
|
|
|
}); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
SparkX::Form::Field::Checkbox - A Checkbox field for SparkX::Form |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
version 0.2102 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 to_html() => Str |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Renders the field to HTML |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 to_xhtml() => Str |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Renders the field to XHTML |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 validate() => Bool |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Validates the field. Before composition with validators, always returns 1. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SEE ALSO |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item L<SparkX::Form> - The forms module this is to be used with |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item L<SparkX::Form::BasicFields> - A collection of fields for use with C<Spark::Form> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
James Laver L<http://jameslaver.com> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2009 by James Laver C<< <sprintf qw(%s@%s.%s cpan jameslaver com)> >>. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|