Skip to content

Commit 73a8d78

Browse files
committed
Bugfix for default titles
Fixes #67
1 parent f847e2e commit 73a8d78

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/services/schema-form.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ angular.module('schemaForm').provider('schemaForm',['sfPathProvider', function(s
4545
var stdFormObj = function(name,schema,options) {
4646
options = options || {};
4747
var f = options.global && options.global.formDefaults ? angular.copy(options.global.formDefaults) : {};
48-
4948
if (options.global && options.global.supressPropertyTitles === true) {
5049
f.title = schema.title;
5150
} else {
52-
f.title = schema.title || name[0];
51+
f.title = schema.title || name;
5352
}
5453

5554
if (schema.description) f.description = schema.description;
@@ -193,7 +192,7 @@ angular.module('schemaForm').provider('schemaForm',['sfPathProvider', function(s
193192
var arrPath = options.path.slice();
194193
arrPath.push('');
195194

196-
f.items = [defaultFormDefinition(options.path,schema.items,{
195+
f.items = [defaultFormDefinition(name,schema.items,{
197196
path: arrPath,
198197
required: required || false,
199198
lookup: options.lookup,
@@ -355,11 +354,10 @@ angular.module('schemaForm').provider('schemaForm',['sfPathProvider', function(s
355354

356355
if (schema.type === "object") {
357356
angular.forEach(schema.properties,function(v,k){
358-
k = [k];
359357
if (ignore[k] !== true) {
360358
var required = schema.required && schema.required.indexOf(k[k.length - 1]) !== -1;
361359
var def = defaultFormDefinition(k,v,{
362-
path: k, //path to this property in dot notation. Root object has no name
360+
path: [k], //path to this property in bracket notation. Root object has no name
363361
lookup: lookup, //extra map to register with. Optimization for merger.
364362
ignore: ignore, //The ignore list of paths (sans root level name)
365363
required: required, //Is it required? (v4 json schema style)

test/schema-form-test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ describe('Schema form',function(){
283283

284284
//A button with default style
285285
scope.form = [{ type: 'button', style: 'btn-success', title: 'Okidoki'}];
286-
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="obj"></form>');
286+
tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="obj"></form>');
287287
$compile(tmpl)(scope);
288288
$rootScope.$apply();
289289

@@ -1807,7 +1807,7 @@ describe('Schema form',function(){
18071807
"type": "fieldset",
18081808
"items": [
18091809
{
1810-
"title": "l",
1810+
"title": "left",
18111811
"schema": {
18121812
"type": "string"
18131813
},
@@ -1820,7 +1820,7 @@ describe('Schema form',function(){
18201820
"type": "text"
18211821
},
18221822
{
1823-
"title": "r",
1823+
"title": "right",
18241824
"schema": {
18251825
"type": "string"
18261826
},
@@ -1838,6 +1838,7 @@ describe('Schema form',function(){
18381838
}
18391839
];
18401840

1841+
18411842
var f = schemaForm.defaults(schema);
18421843
f.form.should.be.deep.equal(form);
18431844

0 commit comments

Comments
 (0)