fixed field sync logic + comments
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / Role / Mutable.pm
index 422c33b..06e7e72 100644 (file)
@@ -30,8 +30,12 @@ sub adopt_value {
   $self->needs_sync(1); # if $self->has_attribute;
 }
 
+
 sub can_sync_to_action {
   my $self = shift;
+
+  # if field is already sync'ed, it can be sync'ed again
+  # this will make sync_to_action no-op if needs_sync is 0
   return 1 unless $self->needs_sync;
   my $attr = $self->attribute;
 
@@ -45,12 +49,20 @@ sub can_sync_to_action {
       }
     }
   } else {
-    return if $attr->is_required;
+    return if $self->model->attribute_is_required($attr);
   }
   return 1;
 };
+
+
 sub sync_to_action {
   my ($self) = @_;
+
+  # don't sync if we're already synced
+  return unless $self->needs_sync;
+
+  # if we got here, needs_sync is 1
+  # can_sync_to_action will do coercion checks, etc.
   return unless $self->can_sync_to_action;
 
   my $attr = $self->attribute;