diff --git a/index.html b/index.html
index 7423331..656453d 100644
--- a/index.html
+++ b/index.html
@@ -117,10 +117,10 @@
null,
"Required properties supported in both v3 and v4+ spec formats. Last one format takes preference. More info [here](https://github.com/brutusin/json-forms/issues/56)"],
["Radio button and checkbox",
- {"$schema":"http://json-schema.org/draft-03/schema#","type":"object","properties":{"radio1":{"type":"boolean","format":"radio","title":"Animal","required":true,"enum":["Dog","Cat","Bird"]},"checkbox":{"type":"boolean","format":"checkbox","title":"Transportation","required":true,"enum":["Vehicle","Airplane","Cruise"]}}},
+ {"$schema":"http://json-schema.org/draft-03/schema#","type":"object","properties":{"radio1":{"type":"boolean","format":"radio","title":"Animal","required":true,"enum":["Dog","Cat","Bird"]},"checkbox":{"type":"boolean","format":"checkbox","title":"Transportation","required":true,"enum":["Vehicle","Airplane","Cruise"]}}},
null,
null,
- "Boolean supporting radio and checkbox type. Must define `format` and `enum` fields."]
+ "Boolean supporting radio and checkbox type. Must define `format` and `enum` fields."],
["Additional input type format",
{"$schema":"http://json-schema.org/draft-03/schema#","type":"object","properties":{"password":{"title":"Password","type":"string","format":"password","description":"Password field would have the text masked.","required":true},"email":{"title":"Email","type":"string","format":"email","description":"Email field would need to follow the format of name@domain.com in order to pass the validation.","required":true},"date":{"title":"Date","type":"string","format":"date","description":"Use the date picker to pick the date.","required":true},"time":{"title":"Time","type":"string","format":"time","description":"Use the time picker to pick the time.","required":true}}},
null,
diff --git a/src/js/brutusin-json-forms.js b/src/js/brutusin-json-forms.js
index c94413a..954e482 100644
--- a/src/js/brutusin-json-forms.js
+++ b/src/js/brutusin-json-forms.js
@@ -930,6 +930,9 @@ if (typeof brutusin === "undefined") {
if (object.length === 0) {
return null;
}
+ if (s.format === "checkbox") {
+ return object;
+ }
var clone = new Array();
for (var i = 0; i < object.length; i++) {
clone[i] = removeEmptiesAndNulls(object[i], s.items);
@@ -1394,6 +1397,19 @@ if (typeof brutusin === "undefined") {
if (!value) {
value = false;
}
+ } else if (schema.format === "checkbox") {
+ var checkboxValue = [];
+ for (var i = 0; i < input.childElementCount; i++) {
+ if (input.childNodes[i].tagName === "INPUT" && input.childNodes[i].checked) {
+ checkboxValue.push(input.childNodes[i].value);
+ }
+ }
+ if (checkboxValue.length !== 0) {
+ value = checkboxValue;
+ }
+ else {
+ value = null;
+ }
} else if (input.tagName.toLowerCase() === "select") {
if (input.value === "true") {
value = true;