Commit | Line | Data |
ddccc6a2 |
1 | package Reaction::UI::ViewPort::Field::Mutable::Boolean; |
2 | |
3 | use Reaction::Class; |
4 | |
81393881 |
5 | use namespace::clean -except => [ qw(meta) ]; |
6 | extends 'Reaction::UI::ViewPort::Field::Boolean'; |
62ffa273 |
7 | |
81393881 |
8 | with 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple'; |
9 | sub adopt_value_string { |
10 | my ($self) = @_; |
3d336c55 |
11 | $self->value($self->value_string||0); |
81393881 |
12 | }; |
13 | sub BUILD { |
14 | my($self) = @_; |
15 | $self->value(0) unless $self->_model_has_value; |
16 | }; |
3fad510b |
17 | |
7ccc8c72 |
18 | # yeah, bool fields have to always be required |
19 | # otherwise we ever cant get false |
20 | # for reference, take a peek in Field::Role::Mutable::Simple's |
21 | # is_modified logic |
22 | sub value_is_required { 1 } |
23 | |
81393881 |
24 | __PACKAGE__->meta->make_immutable; |
3fad510b |
25 | |
ddccc6a2 |
26 | |
27 | 1; |