has message => (is => 'rw', isa => 'Str', clearer => 'clear_message');
+has is_modified => (
+ is => 'ro', writer => '_set_modified',
+ required => 1, default => 1, init_arg => undef
+);
+
after clear_value => sub {
my $self = shift;
$self->clear_message if $self->has_message;
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;
required => 1,
);
+sub is_modified {
+ my $self = shift;
+ foreach my $field (@{$self->fields}) {
+ return 1 if $field->is_modified;
+ }
+ return 0;
+}
+
sub _build_fields_for_type_Num {
my ($self, $attr, $args) = @_;
$self->_build_simple_field(attribute => $attr, class => Number, %$args);