Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit 06f7cfd

Browse files
committed
v7.3.8
2 parents cc8ba00 + 0e69c1b commit 06f7cfd

File tree

6 files changed

+57
-9
lines changed

6 files changed

+57
-9
lines changed

dist/formly.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* angular-formly JavaScript Library v7.3.7
2+
* angular-formly JavaScript Library v7.3.8
33
*
44
* @license MIT (http://license.angular-formly.com)
55
*
@@ -153,7 +153,7 @@ return /******/ (function(modules) { // webpackBootstrap
153153

154154
ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
155155
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
156-
ngModule.constant('formlyVersion', ("7.3.7")); // <-- webpack variable
156+
ngModule.constant('formlyVersion', ("7.3.8")); // <-- webpack variable
157157

158158
ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
159159
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
@@ -424,7 +424,7 @@ return /******/ (function(modules) { // webpackBootstrap
424424
Object.defineProperty(exports, "__esModule", {
425425
value: true
426426
});
427-
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.3.7") + "/other/ERRORS_AND_WARNINGS.md#";
427+
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.3.8") + "/other/ERRORS_AND_WARNINGS.md#";
428428
module.exports = exports["default"];
429429

430430
/***/ },
@@ -1393,6 +1393,10 @@ return /******/ (function(modules) { // webpackBootstrap
13931393
resetFormControl($scope.options.formControl);
13941394
}
13951395
}
1396+
if ($scope.form) {
1397+
$scope.form.$setUntouched && $scope.form.$setUntouched();
1398+
$scope.form.$setPristine();
1399+
}
13961400
}
13971401

13981402
function resetFormControl(formControl, isMultiNgModel) {

dist/formly.min.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formly.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-formly",
3-
"version": "7.3.7",
3+
"version": "7.3.8",
44
"author": "Astrism <[email protected]>",
55
"contributors": [
66
"Astrism <[email protected]>",

src/directives/formly-field.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
197197
resetFormControl($scope.options.formControl)
198198
}
199199
}
200+
if ($scope.form) {
201+
$scope.form.$setUntouched && $scope.form.$setUntouched()
202+
$scope.form.$setPristine()
203+
}
200204
}
201205

202206
function resetFormControl(formControl, isMultiNgModel) {

src/directives/formly-field.test.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,6 @@ describe('formly-field', function() {
13091309
// initial state
13101310
expect(field.formControl.$dirty).to.be.false
13111311
expect(field.formControl.$touched).to.be.false
1312-
13131312
// modification
13141313
scope.model.foo = '~=[,,_,,]:3'
13151314
field.formControl.$setTouched()
@@ -1427,6 +1426,43 @@ describe('formly-field', function() {
14271426
expect(() => field.resetModel()).to.not.throw()
14281427
})
14291428

1429+
it('should reset the form state on the input and form both', () => {
1430+
const field = getNewField({key: 'foo'})
1431+
scope.fields = [field]
1432+
compileAndDigest(`
1433+
<form name="theForm">
1434+
<formly-form form="theForm" model="model" fields="fields" options="options"></formly-form>
1435+
</form>
1436+
`)
1437+
// initial state
1438+
expect(field.formControl.$dirty).to.be.false
1439+
expect(field.formControl.$touched).to.be.false
1440+
expect(scope.theForm.$dirty).to.be.false
1441+
expect(scope.theForm.$pristine).to.be.true
1442+
// modification
1443+
scope.model.foo = '~=[,,_,,]:3'
1444+
field.formControl.$setTouched()
1445+
field.formControl.$setDirty()
1446+
scope.$digest()
1447+
1448+
// expect modification
1449+
expect(field.formControl.$dirty).to.be.true
1450+
expect(field.formControl.$touched).to.be.true
1451+
expect(scope.theForm.$dirty).to.be.true
1452+
expect(scope.theForm.$pristine).to.be.false
1453+
expect(field.formControl.$modelValue).to.eq('~=[,,_,,]:3')
1454+
1455+
// reset state
1456+
field.resetModel()
1457+
1458+
// expect reset
1459+
expect(field.formControl.$modelValue).to.be.empty
1460+
expect(field.formControl.$touched).to.be.false
1461+
expect(field.formControl.$dirty).to.be.false
1462+
expect(scope.theForm.$dirty).to.be.false
1463+
expect(scope.theForm.$pristine).to.be.true
1464+
})
1465+
14301466
it(`should not digest if there's a digest in progress`, () => {
14311467
scope.fields = [getNewField()]
14321468
compileAndDigest()

0 commit comments

Comments
 (0)