Skip to content

Commit 0304c05

Browse files
committed
Merge pull request #40 from torstenrudolf/development
fixed default setting of boolean fields with default false
2 parents 7255938 + 4d1f601 commit 0304c05

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/services/schema-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ angular.module('schemaForm').provider('schemaForm',[function(){
2525
if (schema.title) f.title = schema.title;
2626
if (schema.description) f.description = schema.description;
2727
if (options.required === true || schema.required === true) f.required = true;
28-
if (schema.default) f.default = schema.default;
28+
if (schema.default !== undefined) f.default = schema.default;
2929
if (schema.maxLength) f.maxlength = schema.maxLength;
3030
if (schema.minLength) f.minlength = schema.maxLength;
3131
if (schema.readOnly || schema.readonly) f.readonly = schema.readOnly || schema.readonly;

test/schema-form-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,11 @@ describe('Schema form',function(){
16341634
"NaN",
16351635
]
16361636
},
1637+
"overEighteen": {
1638+
"title": "Are you over 18 years old?",
1639+
"type": "boolean",
1640+
"default": false
1641+
},
16371642
"attributes": {
16381643
"type": "object",
16391644
"required": ['eyecolor'],
@@ -1684,6 +1689,17 @@ describe('Schema form',function(){
16841689
]
16851690
}
16861691
},
1692+
{
1693+
title: 'Are you over 18 years old?',
1694+
key: 'overEighteen',
1695+
type: 'checkbox',
1696+
default: false,
1697+
schema: {
1698+
"title": "Are you over 18 years old?",
1699+
"type": "boolean",
1700+
"default": false
1701+
}
1702+
},
16871703
{
16881704
type: "fieldset",
16891705
items: [

0 commit comments

Comments
 (0)