Skip to content

Commit fc1bce4

Browse files
committed
Docs for sf-insert-field
1 parent b6b2907 commit fc1bce4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/index.md

+36
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Documentation
2525
1. [array](#array)
2626
1. [tabarray](#tabarray)
2727
1. [Post process function](#post-process-function)
28+
1. [Manual field insertion](#manual-field-insertion)
2829
1. [Extending Schema Form](extending.md)
2930

3031
Basic Usage
@@ -1010,3 +1011,38 @@ angular.module('myModule', ['schemaForm']).config(function(schemaFormProvider){
10101011

10111012
});
10121013
```
1014+
1015+
1016+
1017+
### Manual field insertion
1018+
There is a limited feature for controlling manually where a generated field should go so you can
1019+
,as an example, wrap it in custom html. Consider the feature experimental.
1020+
1021+
It has a number of drawbacks though.
1022+
1023+
1. You can only insert fields that are in the root level of your form definition, i.e. not inside fieldset, arrays etc.
1024+
1. Generated fields are always last in the form so if you don't supply slots for all of your top level fields the rest goes below.
1025+
1. To match "keys" of forms we match against the internal array format, hence the key "name" becomes "['name']" and "foo.bar" becomes "['foo']['bar']"
1026+
1027+
Define "slots" for the generated field by adding an element with the attribute `sf-insert-field`
1028+
1029+
ex.
1030+
```js
1031+
$scope.form = [
1032+
"name",
1033+
"email",
1034+
"comment"
1035+
]
1036+
```
1037+
1038+
```html
1039+
<form sf-model="model"
1040+
sf-form="form"
1041+
sf-schema="schema">
1042+
<em>before</em>
1043+
<div sf-insert-field="['email']"></div>
1044+
<em>after</em>
1045+
1046+
<!-- the rest of the form, i.e. name and comment will be generated here -->
1047+
</form>
1048+
```

0 commit comments

Comments
 (0)