| 1 | package Form::Sensible::Field::Toggle; | ||
| 2 | |||
| 3 | 16 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 16 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 16 | extends 'Form::Sensible::Field::Select'; | |
| 6 | |||
| 7 | ## provides a simple on/off field | ||
| 8 | |||
| 9 | 16 | has 'on_value' => ( | |
| 10 | is => 'rw', | ||
| 11 | default => 'on', | ||
| 12 | ); | ||
| 13 | |||
| 14 | 16 | has 'off_value' => ( | |
| 15 | is => 'rw', | ||
| 16 | default => 'off', | ||
| 17 | ); | ||
| 18 | |||
| 19 | has 'on_label' => ( | ||
| 20 | is => 'rw', | ||
| 21 | isa => 'Str', | ||
| 22 | lazy => 1, | ||
| 23 | 0 | ▶ | default => sub { ucfirst(shift->on_value)}, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 24 | 16 | ); | |
| 25 | |||
| 26 | has 'off_label' => ( | ||
| 27 | is => 'rw', | ||
| 28 | isa => 'Str', | ||
| 29 | lazy => 1, | ||
| 30 | 0 | ▶ | default => sub { ucfirst(shift->off_value)}, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 31 | 16 | ); | |
| 32 | |||
| 33 | |||
| 34 | 0 | ▶ | sub get_additional_configuration { |
|
Subroutine
get_additional_configuration: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 35 | 0 | my $self = shift; | |
| 36 | |||
| 37 | return { | ||
| 38 | 0 | map { $_ => $self->$_ } | |
| 39 | qw/on_value off_value on_label off_label/ | ||
| 40 | }; | ||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 44 | 0 | ▶ | sub options { |
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 45 | 0 | my $self = shift; | |
| 46 | |||
| 47 | return [ { | ||
| 48 | 0 | name => $self->on_label, | |
| 49 | value => $self->on_value | ||
| 50 | }, | ||
| 51 | { | ||
| 52 | name => $self->off_label, | ||
| 53 | value => $self->off_value | ||
| 54 | }, | ||
| 55 | ]; | ||
| 56 | } | ||
| 57 | |||
| 58 | 0 | ▶ | sub accepts_multiple { |
|
Subroutine
accepts_multiple: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 59 | 0 | my $self = shift; | |
| 60 | 0 | return 0; | |
| 61 | } | ||
| 62 | |||
| 63 | 16 | __PACKAGE__->meta->make_immutable; | |
| 64 | 16 | 1; | |
| 65 | |||
| 66 | __END__ | ||