aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2009-01-24 00:48:47 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2009-01-24 00:48:47 +0000
commit029c34a8754728e0f1622ea56ac112941226ebd3 (patch)
treeeab03dc6678e4bfcc38b54288807f4ef04ff6058 /lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
parent67426720ad198d5689825c4173b68dad6cab75df (diff)
downloadreaction-029c34a8754728e0f1622ea56ac112941226ebd3.tar.gz
reaction-029c34a8754728e0f1622ea56ac112941226ebd3.zip
basic is_modified support
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm')
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
index e41f264..e19fa61 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
@@ -12,9 +12,21 @@ has value_string => (
clearer => 'clear_value',
);
+has '+is_modified' => (default => 0);
+
around value_string => sub {
my $orig = shift;
my $self = shift;
+ if (@_) {
+ # recursive call. be VERY careful we don't go infinite here
+ my $old = $self->value_string;
+ my $new = $_[0];
+ if ((defined $old xor defined $new) || (defined $old && $old ne $new)) {
+ $self->_set_modified(1);
+ } else {
+ return;
+ }
+ }
if (@_ && defined($_[0]) && !ref($_[0]) && $_[0] eq ''
&& !$self->value_is_required) {
$self->clear_value;