Skip to content

Commit 9d2868e

Browse files
committed
Merge branch 'hotfix/checkboxes'
2 parents b37f208 + a3d630d commit 9d2868e

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

Diff for: CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.8.10
2+
-------
3+
* Bugfix for checkboxes when model array is undefined.
4+
15
v0.8.9
26
------
37
* Bugfix for radios and radios-inline. Validation should now work.

Diff for: dist/schema-form.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -2293,6 +2293,18 @@ function(sel, sfPath, schemaForm) {
22932293
}
22942294
};
22952295

2296+
// If model is undefined make sure it gets set.
2297+
var getOrCreateModel = function() {
2298+
var model = scope.modelArray;
2299+
if (!model) {
2300+
var selection = sfPath.parse(attrs.sfNewArray);
2301+
model = [];
2302+
sel(selection, scope, model);
2303+
scope.modelArray = model;
2304+
}
2305+
return model;
2306+
};
2307+
22962308
// We need the form definition to make a decision on how we should listen.
22972309
var once = scope.$watch('form', function(form) {
22982310
if (!form) {
@@ -2363,7 +2375,7 @@ function(sel, sfPath, schemaForm) {
23632375
//To get two way binding we also watch our titleMapValues
23642376
scope.$watchCollection('titleMapValues', function(vals, old) {
23652377
if (vals && vals !== old) {
2366-
var arr = scope.modelArray;
2378+
var arr = getOrCreateModel();
23672379

23682380
// Apparently the fastest way to clear an array, readable too.
23692381
// http://jsperf.com/array-destroy/32
@@ -2392,13 +2404,7 @@ function(sel, sfPath, schemaForm) {
23922404
var empty;
23932405

23942406
// Create and set an array if needed.
2395-
var model = scope.modelArray;
2396-
if (!model) {
2397-
var selection = sfPath.parse(attrs.sfNewArray);
2398-
model = [];
2399-
sel(selection, scope, model);
2400-
scope.modelArray = model;
2401-
}
2407+
var model = getOrCreateModel();
24022408

24032409
// Same old add empty things to the array hack :(
24042410
if (scope.form && scope.form.schema && scope.form.schema.items) {

Diff for: dist/schema-form.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-schema-form",
3-
"version": "0.8.9",
3+
"version": "0.8.10",
44
"description": "Create complex forms from a JSON schema with angular.",
55
"repository": "Textalk/angular-schema-form",
66
"main": "dist/schema-form.min.js",

Diff for: src/directives/newArray.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ function(sel, sfPath, schemaForm) {
3333
}
3434
};
3535

36+
// If model is undefined make sure it gets set.
37+
var getOrCreateModel = function() {
38+
var model = scope.modelArray;
39+
if (!model) {
40+
var selection = sfPath.parse(attrs.sfNewArray);
41+
model = [];
42+
sel(selection, scope, model);
43+
scope.modelArray = model;
44+
}
45+
return model;
46+
};
47+
3648
// We need the form definition to make a decision on how we should listen.
3749
var once = scope.$watch('form', function(form) {
3850
if (!form) {
@@ -103,7 +115,7 @@ function(sel, sfPath, schemaForm) {
103115
//To get two way binding we also watch our titleMapValues
104116
scope.$watchCollection('titleMapValues', function(vals, old) {
105117
if (vals && vals !== old) {
106-
var arr = scope.modelArray;
118+
var arr = getOrCreateModel();
107119

108120
// Apparently the fastest way to clear an array, readable too.
109121
// http://jsperf.com/array-destroy/32
@@ -132,13 +144,7 @@ function(sel, sfPath, schemaForm) {
132144
var empty;
133145

134146
// Create and set an array if needed.
135-
var model = scope.modelArray;
136-
if (!model) {
137-
var selection = sfPath.parse(attrs.sfNewArray);
138-
model = [];
139-
sel(selection, scope, model);
140-
scope.modelArray = model;
141-
}
147+
var model = getOrCreateModel();
142148

143149
// Same old add empty things to the array hack :(
144150
if (scope.form && scope.form.schema && scope.form.schema.items) {

0 commit comments

Comments
 (0)