Skip to content

Commit a5e07a6

Browse files
committed
allow to define a pre-existing HTML layout where fields will be inserted
1 parent 764599d commit a5e07a6

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

dist/schema-form.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,17 +1259,21 @@ angular.module('schemaForm')
12591259
//make the form available to decorators
12601260
scope.schemaForm = {form: merged, schema: schema};
12611261

1262-
//Create directives from the form definition
1263-
angular.forEach(merged, function(obj, i) {
1264-
var n = document.createElement(attrs.sfDecoratorName ||
1265-
snakeCase(schemaFormDecorators.defaultDecorator, '-'));
1266-
n.setAttribute('form', 'schemaForm.form[' + i + ']');
1267-
frag.appendChild(n);
1268-
});
1269-
12701262
//clean all but pre existing html.
12711263
element.children(':not(.schema-form-ignore)').remove();
12721264

1265+
//Create directives from the form definition
1266+
angular.forEach(merged,function(obj,i){
1267+
var n = document.createElement(attrs.sfDecorator || snake_case(schemaFormDecorators.defaultDecorator,'-'));
1268+
n.setAttribute('form','schemaForm.form['+i+']');
1269+
var slot = element[0].querySelector('*[sf-insert-field="' + obj.key + '"]');
1270+
if(slot) {
1271+
slot.appendChild(n);
1272+
} else {
1273+
frag.appendChild(n);
1274+
}
1275+
});
1276+
12731277
element[0].appendChild(frag);
12741278

12751279
//compile only children

0 commit comments

Comments
 (0)