|
1 |
| -angular-schema-form |
| 1 | +Angular Schema Form |
2 | 2 | ===================
|
3 | 3 |
|
4 | 4 | Generate forms from a JSON schema, with AngularJS!
|
| 5 | + |
| 6 | +Schema Form is a set of AngularJS directives (and a service..) that can create a form directly from a json schema |
| 7 | +definition and also validate against that schema. The defaults may be fine for a lot cases, but you can also |
| 8 | +customize it, changing order and type of fields. |
| 9 | + |
| 10 | + |
| 11 | +Schema Form is inspired by the nice [JSON Form](https://github.com/joshfire/jsonform) library and aims to be roughly |
| 12 | +compatible with it, especially it's form defintion. What sets Schema Form apart from JSON Form is that Schema Form |
| 13 | +aims to be deeply integrated with AngularJS, i.e. to use the standard AngularJS way of handling forms. It also uses |
| 14 | +[tv4](https://github.com/geraintluff/tv4) for validation which means its compatible with version 4 of the json schema |
| 15 | +standard. Schema Form, as a default, generates bootstrap 3 friendly HTML. |
| 16 | + |
| 17 | +Another thing that sets Schema Form apart is that it, at the moment, doesn't implement half of what JSON Form |
| 18 | +does, nor have any documentation! Which of course we hope to remedy soon. |
| 19 | + |
| 20 | + |
| 21 | +Try out the [example](http://textalk.github.io/angular-schema-form/src/bootstrap-example.html) where you can edit |
| 22 | +the schema or the form definition and see what comes out! |
| 23 | + |
| 24 | + |
| 25 | +Basic Usage |
| 26 | +----------- |
| 27 | + |
| 28 | +```html |
| 29 | +<form sf-schema="schema" sf-form="form" sf-model="data"></form> |
| 30 | +``` |
| 31 | + |
| 32 | +```javascript |
| 33 | +function FormController($scope) { |
| 34 | + $scope.schema = { |
| 35 | + type: "object", |
| 36 | + properties: { |
| 37 | + name: { type: "string", minLength: 2, title: "Name", description: "Name or alias" }, |
| 38 | + title: { |
| 39 | + type: "string", |
| 40 | + enum: ['dr','jr','sir','mrs','mr','NaN','dj'] |
| 41 | + } |
| 42 | + }; |
| 43 | + |
| 44 | + |
| 45 | + $scope.form = [ |
| 46 | + "*", |
| 47 | + { |
| 48 | + type: "submit", |
| 49 | + title: "Save", |
| 50 | + } |
| 51 | + ]; |
| 52 | + |
| 53 | + $scope.data = {}; |
| 54 | +} |
| 55 | +``` |
| 56 | +
|
| 57 | +
|
| 58 | +
|
| 59 | +
|
0 commit comments