| 1 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package HTML::Widget::Plugin::Checkbox; | ||||||||||
| 4 | # ABSTRACT: it's either [ ] or [x] | ||||||||||
| 5 | 15 | $HTML::Widget::Plugin::Checkbox::VERSION = '0.204'; | |||||||||
| 6 | 15 | ▶ | use parent 'HTML::Widget::Plugin'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | #pod =head1 SYNOPSIS | ||||||||||
| 9 | #pod | ||||||||||
| 10 | #pod $widget_factory->checkbox({ | ||||||||||
| 11 | #pod id => 'checkbox-id', # also used as default for control name | ||||||||||
| 12 | #pod value => 'checkbox-value', # -not- the "am I checked?" setting | ||||||||||
| 13 | #pod checked => $true_or_false, | ||||||||||
| 14 | #pod }); | ||||||||||
| 15 | #pod | ||||||||||
| 16 | #pod =head1 DESCRIPTION | ||||||||||
| 17 | #pod | ||||||||||
| 18 | #pod This plugin provides a widget for boolean checkbox widgets. | ||||||||||
| 19 | #pod | ||||||||||
| 20 | #pod =cut | ||||||||||
| 21 | |||||||||||
| 22 | 15 | ▶ | use HTML::Element; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | #pod =head1 METHODS | ||||||||||
| 25 | #pod | ||||||||||
| 26 | #pod =head2 C< provided_widgets > | ||||||||||
| 27 | #pod | ||||||||||
| 28 | #pod This plugin provides the following widgets: checkbox | ||||||||||
| 29 | #pod | ||||||||||
| 30 | #pod =cut | ||||||||||
| 31 | |||||||||||
| 32 | 16 | ▶ | sub provided_widgets { qw(checkbox) } | ||||||||
|
Subroutine
provided_widgets: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 33 | |||||||||||
| 34 | #pod =head2 C< checkbox > | ||||||||||
| 35 | #pod | ||||||||||
| 36 | #pod This method returns a checkbox widget. | ||||||||||
| 37 | #pod | ||||||||||
| 38 | #pod In addition to the generic L<HTML::Widget::Plugin> attributes, the following | ||||||||||
| 39 | #pod are valid arguments: | ||||||||||
| 40 | #pod | ||||||||||
| 41 | #pod =over | ||||||||||
| 42 | #pod | ||||||||||
| 43 | #pod =item checked | ||||||||||
| 44 | #pod | ||||||||||
| 45 | #pod This is the widget's initial state. If true, the checkbox is checked. | ||||||||||
| 46 | #pod Otherwise, it is not. | ||||||||||
| 47 | #pod | ||||||||||
| 48 | #pod =item value | ||||||||||
| 49 | #pod | ||||||||||
| 50 | #pod This is the value for the checkbox, not to be confused with whether or not it | ||||||||||
| 51 | #pod is checked. | ||||||||||
| 52 | #pod | ||||||||||
| 53 | #pod =back | ||||||||||
| 54 | #pod | ||||||||||
| 55 | #pod =cut | ||||||||||
| 56 | |||||||||||
| 57 | 16 | ▶ | sub _attribute_args { qw(checked disabled value) } | ||||||||
|
Subroutine
_attribute_args: called CC=1 SCAR=0.0
| |||||||||||
| 58 | 32 | ▶ | sub _boolean_args { qw(checked disabled) } | ||||||||
|
Subroutine
_boolean_args: called CC=1 SCAR=0.0
| |||||||||||
| 59 | |||||||||||
| 60 | 2 | ▶ | sub checkbox { | ||||||||
|
Subroutine
checkbox: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 61 | 2 | my ($self, $factory, $arg) = @_; | |||||||||
| 62 | |||||||||||
| 63 | 2 | $arg->{attr}{type} = 'checkbox'; | |||||||||
| 64 | |||||||||||
| 65 | 2 | ▶ | $arg->{attr}{name} = $arg->{attr}{id} if not defined $arg->{attr}{name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | |||||||||||
| 67 | 2 | my $widget = HTML::Element->new('input'); | |||||||||
| 68 | |||||||||||
| 69 | 2 | $widget->attr($_ => $arg->{attr}{$_}) for keys %{ $arg->{attr} }; | |||||||||
| 70 | 2 | return $widget->as_XML; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 15 | 1; | |||||||||
| 74 | |||||||||||
| 75 | __END__ | ||||||||||