Skip to content

Add check for schema property to prevent form generation failures whe… #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/services/schema-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,14 @@ angular.module('schemaForm').provider('schemaForm',

// Special case: checkbox
// Since have to ternary state we need a default
if (obj.type === 'checkbox' && angular.isUndefined(obj.schema['default'])) {
obj.schema['default'] = false;
if (obj.type === 'checkbox') {
// Check for schema property, as the checkbox may be part of the explicitly defined form
if (obj.schema === undefined) {
obj.schema = { default: false };
}
else if (obj.schema['default'] === undefined) {
obj.schema['default'] = false;
}
}

// Special case: template type with tempplateUrl that's needs to be loaded before rendering
Expand Down