From 04329151d2df833f803629cefa781aa6409fe6a5 Mon Sep 17 00:00:00 2001 From: Kai Groner Date: Wed, 6 Jun 2012 23:23:43 -0400 Subject: [PATCH] fix(FormController): propagate dirty state to parent forms --- src/ng/directive/form.js | 1 + test/ng/directive/formSpec.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index 6b876e01be0e..4f06f0936c38 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -117,6 +117,7 @@ function FormController(element, attrs) { element.removeClass(PRISTINE_CLASS).addClass(DIRTY_CLASS); form.$dirty = true; form.$pristine = false; + parentForm.$setDirty(); }; } diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js index 51c6929fc84d..2fd55f607eef 100644 --- a/test/ng/directive/formSpec.js +++ b/test/ng/directive/formSpec.js @@ -284,6 +284,9 @@ describe('form', function() { inputB.$setValidity('MyError', true); expect(parent.$error.MyError).toBe(false); expect(child.$error.MyError).toBe(false); + + child.$setDirty(); + expect(parent.$dirty).toBeTruthy(); });