@@ -4,6 +4,7 @@ Documentation
441 . [ Basic Usage] ( #basic-usage )
551 . [ Handling Submit] ( #handling-submit )
661 . [ Global Options] ( #global-options )
7+ 1 . [ Form defaults in schema] ( #form-defaults-in-schema )
781 . [ Form types] ( #form-types )
891 . [ Default form types] ( #default-form-types )
9101 . [ Form definitions] ( #form-definitions )
@@ -25,6 +26,7 @@ Documentation
2526 1 . [ array] ( #array )
2627 1 . [ tabarray] ( #tabarray )
27281 . [ Post process function] ( #post-process-function )
29+ 1 . [ Events] ( #events )
28301 . [ Manual field insertion] ( #manual-field-insertion )
29311 . [ Extending Schema Form] ( extending.md )
3032
173175< / div>
174176` ` `
175177
178+ Form defaults in schema
179+ -----------------------
180+ Its recommended to split presentation and validation into a form definition and a json schema. But
181+ if you for some reason can't do this, but *do* have the power to change the schema, you can supply form
182+ default values within the schema using the custom attribute ` x- schema- form` . ` x- schema- form` should
183+ be a form object and acts as form definition defaults for that field.
176184
185+ Example schema.
186+ ` ` ` js
187+ {
188+ " type" : " object" ,
189+ " properties" : {
190+ " comment" : {
191+ " type" : " string" ,
192+ " title" : " Comment" ,
193+ " x-schema-form" : {
194+ " type" : " textarea" ,
195+ " placeholder" : " Don't hold back"
196+ }
197+ }
198+ }
199+ }
200+ ` ` `
177201
178202Form types
179203----------
@@ -314,8 +338,10 @@ General options most field types can handle:
314338 feedback: false , // Inline feedback icons
315339 placeholder: " Input..." , // placeholder on inputs and textarea
316340 ngModelOptions: { ... }, // Passed along to ng-model-options
317- readonly: true // Same effect as readOnly in schema. Put on a fieldset or array
341+ readonly: true , // Same effect as readOnly in schema. Put on a fieldset or array
318342 // and their items will inherit it.
343+ htmlClass: " street foobar" , // CSS Class(es) to be added to the container div
344+ fieldHtmlClass: " street" // CSS Class(es) to be added to field input (or similar)
319345}
320346` ` `
321347
@@ -836,6 +862,9 @@ need the reordering.
836862In the form definition you can refer to properties of an array item by the empty
837863bracket notation. In the ` key` simply end the name of the array with ` []`
838864
865+ By default the array will start with one *undefined* value so that the user is presented with one a
866+ form, to supress this the attribute ` startEmpty` to ` true `
867+
839868Given the schema:
840869` ` ` json
841870{
@@ -888,7 +917,7 @@ function FormCtrl($scope) {
888917
889918Example with sub form, note that you can get rid of the form field the object wrapping the
890919subform fields gives you per default by using the ` items` option in the
891- form definition.
920+ form definition, also example of ` startEmpty ` .
892921
893922` ` ` javascript
894923function FormCtrl ($scope ) {
@@ -926,7 +955,8 @@ function FormCtrl($scope) {
926955 " subforms[].nick" ,
927956 " subforms[].name" ,
928957 " subforms[].emails" ,
929- ]
958+ ],
959+ startEmpty: true
930960 }
931961 ];
932962}
@@ -1029,7 +1059,14 @@ angular.module('myModule', ['schemaForm']).config(function(schemaFormProvider){
10291059});
10301060` ` `
10311061
1062+ Events
1063+ ---------------------
1064+ Events are emitted or broadcast at various points in the process of rendering or validating the
1065+ form. Below is a list of these events and how they are propagated.
10321066
1067+ | Event | When | Type | Arguments |
1068+ |:--------------------:|:----------------------:|:-----:|:----------------------------------:|
1069+ | ` sf- render- finished` | After form is rendered | emit | The sf-schema directives's element |
10331070
10341071### Manual field insertion
10351072There is a limited feature for controlling manually where a generated field should go so you can
0 commit comments