1 package Reaction::UI::ViewPort::DisplayField::Boolean;
4 use aliased 'Reaction::UI::ViewPort::DisplayField';
6 class Boolean, is DisplayField, which {
7 has '+value' => (isa => 'Bool');
8 #has '+layout' => (default => 'displayfield/value_string');
10 has value_string => (isa => 'Str', is => 'rw', lazy_build => 1);
12 has value_string_format =>
13 (isa => 'HashRef', is => 'rw', required => 1,
14 default => sub { {true => 'Yes', false => 'No'} }
17 implements build_value_string => as {
19 my $val = $self->value;
20 if(!defined $val || $val eq "" || "$val" eq '0'){
21 return $self->value_string_format->{false};
22 } elsif("$val" eq '1'){
23 return $self->value_string_format->{true};
24 } else{ #this will hopefully never happen
25 confess "Not supporting some type of Bool value";